| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/favicon/favicon_tab_helper.h" | 10 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 11 #include "chrome/browser/history/history_types.h" |
| 12 #include "chrome/browser/history/top_sites.h" |
| 9 #include "chrome/browser/instant/instant_commit_type.h" | 13 #include "chrome/browser/instant/instant_commit_type.h" |
| 10 #include "chrome/browser/instant/instant_ntp.h" | 14 #include "chrome/browser/instant/instant_ntp.h" |
| 11 #include "chrome/browser/instant/instant_overlay.h" | 15 #include "chrome/browser/instant/instant_overlay.h" |
| 12 #include "chrome/browser/instant/instant_service.h" | 16 #include "chrome/browser/instant/instant_service.h" |
| 13 #include "chrome/browser/instant/instant_service_factory.h" | 17 #include "chrome/browser/instant/instant_service_factory.h" |
| 14 #include "chrome/browser/instant/instant_tab.h" | 18 #include "chrome/browser/instant/instant_tab.h" |
| 15 #include "chrome/browser/instant/instant_test_utils.h" | 19 #include "chrome/browser/instant/instant_test_utils.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/themes/theme_service.h" |
| 22 #include "chrome/browser/themes/theme_service_factory.h" |
| 23 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 17 #include "chrome/browser/ui/search/search.h" | 24 #include "chrome/browser/ui/search/search.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 26 #include "chrome/browser/ui/webui/theme_source.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/thumbnail_score.h" |
| 21 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "chrome/test/base/interactive_test_utils.h" | 32 #include "chrome/test/base/interactive_test_utils.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 33 #include "chrome/test/base/ui_test_utils.h" |
| 24 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/render_process_host.h" | 35 #include "content/public/browser/render_process_host.h" |
| 36 #include "content/public/browser/render_view_host.h" |
| 26 #include "content/public/browser/site_instance.h" | 37 #include "content/public/browser/site_instance.h" |
| 38 #include "content/public/browser/url_data_source.h" |
| 27 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/browser/web_contents_view.h" | 40 #include "content/public/browser/web_contents_view.h" |
| 41 #include "content/public/common/bindings_policy.h" |
| 29 #include "content/public/test/browser_test_utils.h" | 42 #include "content/public/test/browser_test_utils.h" |
| 43 #include "third_party/skia/include/core/SkBitmap.h" |
| 30 | 44 |
| 31 class InstantExtendedTest : public InstantTestBase { | 45 namespace { |
| 46 |
| 47 // Creates a bitmap of the specified color. Caller takes ownership. |
| 48 gfx::Image CreateBitmap(SkColor color) { |
| 49 SkBitmap thumbnail; |
| 50 thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4); |
| 51 thumbnail.allocPixels(); |
| 52 thumbnail.eraseColor(color); |
| 53 return gfx::Image::CreateFrom1xBitmap(thumbnail); // adds ref. |
| 54 } |
| 55 |
| 56 } // namespace |
| 57 |
| 58 class InstantExtendedTest : public InProcessBrowserTest, |
| 59 public InstantTestBase { |
| 32 public: | 60 public: |
| 33 InstantExtendedTest() | 61 InstantExtendedTest() |
| 34 : on_most_visited_change_calls_(0), | 62 : on_most_visited_change_calls_(0), |
| 35 most_visited_items_count_(0), | 63 most_visited_items_count_(0), |
| 36 first_most_visited_item_id_(0) { | 64 first_most_visited_item_id_(0) { |
| 37 } | 65 } |
| 38 protected: | 66 protected: |
| 39 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 67 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 40 chrome::search::EnableInstantExtendedAPIForTesting(); | 68 chrome::search::EnableInstantExtendedAPIForTesting(); |
| 41 ASSERT_TRUE(https_test_server_.Start()); | 69 ASSERT_TRUE(https_test_server().Start()); |
| 42 instant_url_ = https_test_server_. | 70 GURL instant_url = https_test_server().GetURL( |
| 43 GetURL("files/instant_extended.html?strk=1&"); | 71 "files/instant_extended.html?strk=1&"); |
| 44 } | 72 InstantTestBase::Init(instant_url); |
| 45 | |
| 46 void FocusOmniboxAndWaitForInstantSupport() { | |
| 47 content::WindowedNotificationObserver ntp_observer( | |
| 48 chrome::NOTIFICATION_INSTANT_NTP_SUPPORT_DETERMINED, | |
| 49 content::NotificationService::AllSources()); | |
| 50 content::WindowedNotificationObserver overlay_observer( | |
| 51 chrome::NOTIFICATION_INSTANT_OVERLAY_SUPPORT_DETERMINED, | |
| 52 content::NotificationService::AllSources()); | |
| 53 FocusOmnibox(); | |
| 54 ntp_observer.Wait(); | |
| 55 overlay_observer.Wait(); | |
| 56 } | 73 } |
| 57 | 74 |
| 58 std::string GetOmniboxText() { | 75 std::string GetOmniboxText() { |
| 59 return UTF16ToUTF8(omnibox()->GetText()); | 76 return UTF16ToUTF8(omnibox()->GetText()); |
| 60 } | 77 } |
| 61 | 78 |
| 62 void SendDownArrow() { | 79 void SendDownArrow() { |
| 63 omnibox()->model()->OnUpOrDownKeyPressed(1); | 80 omnibox()->model()->OnUpOrDownKeyPressed(1); |
| 64 // Wait for JavaScript to run the key handler by executing a blank script. | 81 // Wait for JavaScript to run the key handler by executing a blank script. |
| 65 EXPECT_TRUE(ExecuteScript(std::string())); | 82 EXPECT_TRUE(ExecuteScript(std::string())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 84 &most_visited_items_count_) && | 101 &most_visited_items_count_) && |
| 85 GetIntFromJS(contents, "firstMostVisitedItemId", | 102 GetIntFromJS(contents, "firstMostVisitedItemId", |
| 86 &first_most_visited_item_id_); | 103 &first_most_visited_item_id_); |
| 87 } | 104 } |
| 88 | 105 |
| 89 int on_most_visited_change_calls_; | 106 int on_most_visited_change_calls_; |
| 90 int most_visited_items_count_; | 107 int most_visited_items_count_; |
| 91 int first_most_visited_item_id_; | 108 int first_most_visited_item_id_; |
| 92 }; | 109 }; |
| 93 | 110 |
| 111 // Test class used to verify chrome-search: scheme and access policy from the |
| 112 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it |
| 113 // loads a theme that provides a background image. |
| 114 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { |
| 115 public: |
| 116 InstantPolicyTest() {} |
| 117 |
| 118 protected: |
| 119 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 120 chrome::search::EnableInstantExtendedAPIForTesting(); |
| 121 ASSERT_TRUE(https_test_server().Start()); |
| 122 GURL instant_url = https_test_server().GetURL( |
| 123 "files/instant_extended.html?strk=1&"); |
| 124 InstantTestBase::Init(instant_url); |
| 125 } |
| 126 |
| 127 void InstallThemeSource() { |
| 128 ThemeSource* theme = new ThemeSource(profile()); |
| 129 content::URLDataSource::Add(profile(), theme); |
| 130 } |
| 131 |
| 132 void InstallThemeAndVerify(const std::string& theme_dir, |
| 133 const std::string& theme_name) { |
| 134 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_dir); |
| 135 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 136 theme_path, 1, ExtensionBrowserTest::browser())); |
| 137 const extensions::Extension* theme = |
| 138 ThemeServiceFactory::GetThemeForProfile( |
| 139 ExtensionBrowserTest::browser()->profile()); |
| 140 ASSERT_NE(static_cast<extensions::Extension*>(NULL), theme); |
| 141 ASSERT_EQ(theme->name(), theme_name); |
| 142 } |
| 143 |
| 144 private: |
| 145 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); |
| 146 }; |
| 147 |
| 94 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { | 148 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { |
| 95 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 149 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 96 EXPECT_TRUE(instant()->extended_enabled_); | 150 EXPECT_TRUE(instant()->extended_enabled_); |
| 97 } | 151 } |
| 98 | 152 |
| 99 // Test that Instant is preloaded when the omnibox is focused. | 153 // Test that Instant is preloaded when the omnibox is focused. |
| 100 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { | 154 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { |
| 101 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 155 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 102 | 156 |
| 103 // Explicitly unfocus the omnibox. | 157 // Explicitly unfocus the omnibox. |
| 104 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 158 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 105 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 159 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 106 | 160 |
| 107 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 161 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 108 EXPECT_FALSE(omnibox()->model()->has_focus()); | 162 EXPECT_FALSE(omnibox()->model()->has_focus()); |
| 109 | 163 |
| 110 // Delete any existing overlay. | 164 // Delete any existing overlay. |
| 111 instant()->overlay_.reset(); | 165 instant()->overlay_.reset(); |
| 112 EXPECT_FALSE(instant()->GetOverlayContents()); | 166 EXPECT_FALSE(instant()->GetOverlayContents()); |
| 113 | 167 |
| 114 // Refocus the omnibox. The InstantController should've preloaded Instant. | 168 // Refocus the omnibox. The InstantController should've preloaded Instant. |
| 115 FocusOmniboxAndWaitForInstantSupport(); | 169 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 116 | 170 |
| 117 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 171 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 118 EXPECT_TRUE(omnibox()->model()->has_focus()); | 172 EXPECT_TRUE(omnibox()->model()->has_focus()); |
| 119 | 173 |
| 120 content::WebContents* overlay = instant()->GetOverlayContents(); | 174 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 121 EXPECT_TRUE(overlay); | 175 EXPECT_TRUE(overlay); |
| 122 | 176 |
| 123 // Check that the page supports Instant, but it isn't showing. | 177 // Check that the page supports Instant, but it isn't showing. |
| 124 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 178 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 125 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 179 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 126 EXPECT_TRUE(instant()->model()->mode().is_default()); | 180 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 127 | 181 |
| 128 // Adding a new tab shouldn't delete or recreate the overlay; otherwise, | 182 // Adding a new tab shouldn't delete or recreate the overlay; otherwise, |
| 129 // what's the point of preloading? | 183 // what's the point of preloading? |
| 130 AddBlankTabAndShow(browser()); | 184 AddBlankTabAndShow(browser()); |
| 131 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 185 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 132 | 186 |
| 133 // Unfocusing and refocusing the omnibox should also preserve the overlay. | 187 // Unfocusing and refocusing the omnibox should also preserve the overlay. |
| 134 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 188 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 135 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 189 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 136 | 190 |
| 137 FocusOmnibox(); | 191 FocusOmnibox(); |
| 138 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 192 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 139 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 193 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 140 } | 194 } |
| 141 | 195 |
| 142 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { | 196 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { |
| 143 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 197 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 144 | 198 |
| 145 // Focus omnibox and confirm overlay isn't shown. | 199 // Focus omnibox and confirm overlay isn't shown. |
| 146 FocusOmniboxAndWaitForInstantSupport(); | 200 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 147 content::WebContents* overlay = instant()->GetOverlayContents(); | 201 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 148 EXPECT_TRUE(overlay); | 202 EXPECT_TRUE(overlay); |
| 149 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 203 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 150 EXPECT_TRUE(instant()->model()->mode().is_default()); | 204 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 151 | 205 |
| 152 // Typing in the omnibox should show the overlay. | 206 // Typing in the omnibox should show the overlay. |
| 153 SetOmniboxTextAndWaitForOverlayToShow("query"); | 207 SetOmniboxTextAndWaitForOverlayToShow("query"); |
| 154 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 208 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 155 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 209 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 156 } | 210 } |
| 157 | 211 |
| 158 // Test that middle clicking on a suggestion opens the result in a new tab. | 212 // Test that middle clicking on a suggestion opens the result in a new tab. |
| 159 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 213 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 160 MiddleClickOnSuggestionOpensInNewTab) { | 214 MiddleClickOnSuggestionOpensInNewTab) { |
| 161 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 215 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 162 FocusOmniboxAndWaitForInstantSupport(); | 216 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 163 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 217 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 164 | 218 |
| 165 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 219 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 166 | 220 |
| 167 // Typing in the omnibox should show the overlay. | 221 // Typing in the omnibox should show the overlay. |
| 168 SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/"); | 222 SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/"); |
| 169 | 223 |
| 170 // Create an event listener that opens the top suggestion in a new tab. | 224 // Create an event listener that opens the top suggestion in a new tab. |
| 171 EXPECT_TRUE(ExecuteScript( | 225 EXPECT_TRUE(ExecuteScript( |
| 172 "var rid = getApiHandle().nativeSuggestions[0].rid;" | 226 "var rid = getApiHandle().nativeSuggestions[0].rid;" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 188 // Check that the new tab URL is as expected. | 242 // Check that the new tab URL is as expected. |
| 189 content::WebContents* new_tab_contents = | 243 content::WebContents* new_tab_contents = |
| 190 browser()->tab_strip_model()->GetWebContentsAt(1); | 244 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 191 EXPECT_EQ("http://www.example.com/", new_tab_contents->GetURL().spec()); | 245 EXPECT_EQ("http://www.example.com/", new_tab_contents->GetURL().spec()); |
| 192 | 246 |
| 193 // Check that there are now two tabs. | 247 // Check that there are now two tabs. |
| 194 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 248 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 195 } | 249 } |
| 196 | 250 |
| 197 // Test that omnibox text is correctly set when overlay is committed with Enter. | 251 // Test that omnibox text is correctly set when overlay is committed with Enter. |
| 198 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 252 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) { |
| 199 OmniboxTextUponEnterCommit) { | 253 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 200 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 254 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 201 FocusOmniboxAndWaitForInstantSupport(); | |
| 202 | 255 |
| 203 // The page will autocomplete once we set the omnibox value. | 256 // The page will autocomplete once we set the omnibox value. |
| 204 EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';")); | 257 EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';")); |
| 205 | 258 |
| 206 // Set the text, and wait for suggestions to show up. | 259 // Set the text, and wait for suggestions to show up. |
| 207 SetOmniboxTextAndWaitForOverlayToShow("santa"); | 260 SetOmniboxTextAndWaitForOverlayToShow("santa"); |
| 208 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); | 261 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); |
| 209 | 262 |
| 210 // Test that the current suggestion is correctly set. | 263 // Test that the current suggestion is correctly set. |
| 211 EXPECT_EQ(ASCIIToUTF16(" claus"), omnibox()->GetInstantSuggestion()); | 264 EXPECT_EQ(ASCIIToUTF16(" claus"), omnibox()->GetInstantSuggestion()); |
| 212 | 265 |
| 213 // Commit the search by pressing Enter. | 266 // Commit the search by pressing Enter. |
| 214 browser()->window()->GetLocationBar()->AcceptInput(); | 267 browser()->window()->GetLocationBar()->AcceptInput(); |
| 215 | 268 |
| 216 // 'Enter' commits the query as it was typed. | 269 // 'Enter' commits the query as it was typed. |
| 217 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); | 270 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); |
| 218 | 271 |
| 219 // Suggestion should be cleared at this point. | 272 // Suggestion should be cleared at this point. |
| 220 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); | 273 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); |
| 221 } | 274 } |
| 222 | 275 |
| 223 // Test that omnibox text is correctly set when committed with focus lost. | 276 // Test that omnibox text is correctly set when committed with focus lost. |
| 224 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 277 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) { |
| 225 OmniboxTextUponFocusLostCommit) { | 278 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 226 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 279 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 227 FocusOmniboxAndWaitForInstantSupport(); | |
| 228 | 280 |
| 229 // Set autocomplete text (grey text). | 281 // Set autocomplete text (grey text). |
| 230 EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';")); | 282 EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';")); |
| 231 | 283 |
| 232 // Set the text, and wait for suggestions to show up. | 284 // Set the text, and wait for suggestions to show up. |
| 233 SetOmniboxTextAndWaitForOverlayToShow("johnny"); | 285 SetOmniboxTextAndWaitForOverlayToShow("johnny"); |
| 234 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); | 286 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); |
| 235 | 287 |
| 236 // Test that the current suggestion is correctly set. | 288 // Test that the current suggestion is correctly set. |
| 237 EXPECT_EQ(ASCIIToUTF16(" depp"), omnibox()->GetInstantSuggestion()); | 289 EXPECT_EQ(ASCIIToUTF16(" depp"), omnibox()->GetInstantSuggestion()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 251 #if defined(OS_MACOSX) | 303 #if defined(OS_MACOSX) |
| 252 #define MAYBE_OmniboxTextUponFocusedCommittedSERP \ | 304 #define MAYBE_OmniboxTextUponFocusedCommittedSERP \ |
| 253 DISABLED_OmniboxTextUponFocusedCommittedSERP | 305 DISABLED_OmniboxTextUponFocusedCommittedSERP |
| 254 #else | 306 #else |
| 255 #define MAYBE_OmniboxTextUponFocusedCommittedSERP \ | 307 #define MAYBE_OmniboxTextUponFocusedCommittedSERP \ |
| 256 OmniboxTextUponFocusedCommittedSERP | 308 OmniboxTextUponFocusedCommittedSERP |
| 257 #endif | 309 #endif |
| 258 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 310 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 259 MAYBE_OmniboxTextUponFocusedCommittedSERP) { | 311 MAYBE_OmniboxTextUponFocusedCommittedSERP) { |
| 260 // Setup Instant. | 312 // Setup Instant. |
| 261 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 313 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 262 FocusOmniboxAndWaitForInstantSupport(); | 314 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 263 | 315 |
| 264 // Do a search and commit it. | 316 // Do a search and commit it. |
| 265 SetOmniboxTextAndWaitForOverlayToShow("hello k"); | 317 SetOmniboxTextAndWaitForOverlayToShow("hello k"); |
| 266 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); | 318 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); |
| 267 browser()->window()->GetLocationBar()->AcceptInput(); | 319 browser()->window()->GetLocationBar()->AcceptInput(); |
| 268 | 320 |
| 269 // With a committed results page, do a search by unfocusing the omnibox and | 321 // With a committed results page, do a search by unfocusing the omnibox and |
| 270 // focusing the contents. | 322 // focusing the contents. |
| 271 SetOmniboxText("hello"); | 323 SetOmniboxText("hello"); |
| 272 // Calling handleOnChange manually to make sure it is called before the | 324 // Calling handleOnChange manually to make sure it is called before the |
| 273 // Focus() call below. | 325 // Focus() call below. |
| 274 EXPECT_TRUE(content::ExecuteScript(instant()->instant_tab()->contents(), | 326 EXPECT_TRUE(content::ExecuteScript(instant()->instant_tab()->contents(), |
| 275 "suggestion = 'hello kitty';" | 327 "suggestion = 'hello kitty';" |
| 276 "handleOnChange();")); | 328 "handleOnChange();")); |
| 277 instant()->instant_tab()->contents()->GetView()->Focus(); | 329 instant()->instant_tab()->contents()->GetView()->Focus(); |
| 278 | 330 |
| 279 // Search term extraction should kick in with the autocompleted text. | 331 // Search term extraction should kick in with the autocompleted text. |
| 280 EXPECT_EQ(ASCIIToUTF16("hello kitty"), omnibox()->GetText()); | 332 EXPECT_EQ(ASCIIToUTF16("hello kitty"), omnibox()->GetText()); |
| 281 | 333 |
| 282 // Suggestion should be cleared at this point. | 334 // Suggestion should be cleared at this point. |
| 283 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); | 335 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); |
| 284 } | 336 } |
| 285 | 337 |
| 286 // This test simulates a search provider using the InstantExtended API to | 338 // This test simulates a search provider using the InstantExtended API to |
| 287 // navigate through the suggested results and back to the original user query. | 339 // navigate through the suggested results and back to the original user query. |
| 288 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { | 340 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { |
| 289 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 341 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 290 FocusOmniboxAndWaitForInstantSupport(); | 342 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 291 | 343 |
| 292 SetOmniboxTextAndWaitForOverlayToShow("hello"); | 344 SetOmniboxTextAndWaitForOverlayToShow("hello"); |
| 293 EXPECT_EQ("hello", GetOmniboxText()); | 345 EXPECT_EQ("hello", GetOmniboxText()); |
| 294 | 346 |
| 295 SendDownArrow(); | 347 SendDownArrow(); |
| 296 EXPECT_EQ("result 1", GetOmniboxText()); | 348 EXPECT_EQ("result 1", GetOmniboxText()); |
| 297 SendDownArrow(); | 349 SendDownArrow(); |
| 298 EXPECT_EQ("result 2", GetOmniboxText()); | 350 EXPECT_EQ("result 2", GetOmniboxText()); |
| 299 SendUpArrow(); | 351 SendUpArrow(); |
| 300 EXPECT_EQ("result 1", GetOmniboxText()); | 352 EXPECT_EQ("result 1", GetOmniboxText()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 317 // TODO(sreeram): Enable this check once @mathp's CL lands: | 369 // TODO(sreeram): Enable this check once @mathp's CL lands: |
| 318 // https://codereview.chromium.org/12179025/ | 370 // https://codereview.chromium.org/12179025/ |
| 319 // browser()->window()->GetLocationBar()->AcceptInput(); | 371 // browser()->window()->GetLocationBar()->AcceptInput(); |
| 320 // EXPECT_EQ("hello", GetOmniboxText()); | 372 // EXPECT_EQ("hello", GetOmniboxText()); |
| 321 } | 373 } |
| 322 | 374 |
| 323 // This test simulates a search provider using the InstantExtended API to | 375 // This test simulates a search provider using the InstantExtended API to |
| 324 // navigate through the suggested results and hitting escape to get back to the | 376 // navigate through the suggested results and hitting escape to get back to the |
| 325 // original user query. | 377 // original user query. |
| 326 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { | 378 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { |
| 327 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 379 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 328 FocusOmniboxAndWaitForInstantSupport(); | 380 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 329 | 381 |
| 330 SetOmniboxTextAndWaitForOverlayToShow("hello"); | 382 SetOmniboxTextAndWaitForOverlayToShow("hello"); |
| 331 EXPECT_EQ("hello", GetOmniboxText()); | 383 EXPECT_EQ("hello", GetOmniboxText()); |
| 332 | 384 |
| 333 SendDownArrow(); | 385 SendDownArrow(); |
| 334 EXPECT_EQ("result 1", GetOmniboxText()); | 386 EXPECT_EQ("result 1", GetOmniboxText()); |
| 335 SendDownArrow(); | 387 SendDownArrow(); |
| 336 EXPECT_EQ("result 2", GetOmniboxText()); | 388 EXPECT_EQ("result 2", GetOmniboxText()); |
| 337 SendEscape(); | 389 SendEscape(); |
| 338 EXPECT_EQ("hello", GetOmniboxText()); | 390 EXPECT_EQ("hello", GetOmniboxText()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 349 | 401 |
| 350 // Commit the search by pressing Enter. | 402 // Commit the search by pressing Enter. |
| 351 // TODO(sreeram): Enable this check once @mathp's CL lands: | 403 // TODO(sreeram): Enable this check once @mathp's CL lands: |
| 352 // https://codereview.chromium.org/12179025/ | 404 // https://codereview.chromium.org/12179025/ |
| 353 // browser()->window()->GetLocationBar()->AcceptInput(); | 405 // browser()->window()->GetLocationBar()->AcceptInput(); |
| 354 // EXPECT_EQ("hello", GetOmniboxText()); | 406 // EXPECT_EQ("hello", GetOmniboxText()); |
| 355 } | 407 } |
| 356 | 408 |
| 357 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) { | 409 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) { |
| 358 // Setup Instant. | 410 // Setup Instant. |
| 359 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 411 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 360 FocusOmniboxAndWaitForInstantSupport(); | 412 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 361 | 413 |
| 362 // NTP contents should be preloaded. | 414 // NTP contents should be preloaded. |
| 363 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 415 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 364 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 416 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 365 EXPECT_TRUE(ntp_contents); | 417 EXPECT_TRUE(ntp_contents); |
| 366 } | 418 } |
| 367 | 419 |
| 368 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) { | 420 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) { |
| 369 // Setup Instant. | 421 // Setup Instant. |
| 370 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 422 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 371 FocusOmniboxAndWaitForInstantSupport(); | 423 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 372 | 424 |
| 373 // NTP contents should be preloaded. | 425 // NTP contents should be preloaded. |
| 374 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 426 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 375 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 427 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 376 EXPECT_TRUE(ntp_contents); | 428 EXPECT_TRUE(ntp_contents); |
| 377 | 429 |
| 378 // Open new tab. Preloaded NTP contents should have been used. | 430 // Open new tab. Preloaded NTP contents should have been used. |
| 379 ui_test_utils::NavigateToURLWithDisposition( | 431 ui_test_utils::NavigateToURLWithDisposition( |
| 380 browser(), | 432 browser(), |
| 381 GURL(chrome::kChromeUINewTabURL), | 433 GURL(chrome::kChromeUINewTabURL), |
| 382 NEW_FOREGROUND_TAB, | 434 NEW_FOREGROUND_TAB, |
| 383 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 435 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 384 content::WebContents* active_tab = | 436 content::WebContents* active_tab = |
| 385 browser()->tab_strip_model()->GetActiveWebContents(); | 437 browser()->tab_strip_model()->GetActiveWebContents(); |
| 386 EXPECT_EQ(ntp_contents, active_tab); | 438 EXPECT_EQ(ntp_contents, active_tab); |
| 387 EXPECT_TRUE(chrome::search::IsInstantNTP(active_tab)); | 439 EXPECT_TRUE(chrome::search::IsInstantNTP(active_tab)); |
| 388 } | 440 } |
| 389 | 441 |
| 390 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) { | 442 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) { |
| 391 // Setup Instant. | 443 // Setup Instant. |
| 392 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 444 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 393 FocusOmniboxAndWaitForInstantSupport(); | 445 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 394 | 446 |
| 395 // NTP contents should be preloaded. | 447 // NTP contents should be preloaded. |
| 396 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 448 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 397 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 449 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 398 EXPECT_TRUE(ntp_contents); | 450 EXPECT_TRUE(ntp_contents); |
| 399 | 451 |
| 400 // Open new tab. Preloaded NTP contents should have been used. | 452 // Open new tab. Preloaded NTP contents should have been used. |
| 401 ui_test_utils::NavigateToURLWithDisposition( | 453 ui_test_utils::NavigateToURLWithDisposition( |
| 402 browser(), | 454 browser(), |
| 403 GURL(chrome::kChromeUINewTabURL), | 455 GURL(chrome::kChromeUINewTabURL), |
| 404 CURRENT_TAB, | 456 CURRENT_TAB, |
| 405 ui_test_utils::BROWSER_TEST_NONE); | 457 ui_test_utils::BROWSER_TEST_NONE); |
| 406 content::WebContents* active_tab = | 458 content::WebContents* active_tab = |
| 407 browser()->tab_strip_model()->GetActiveWebContents(); | 459 browser()->tab_strip_model()->GetActiveWebContents(); |
| 408 EXPECT_EQ(ntp_contents, active_tab); | 460 EXPECT_EQ(ntp_contents, active_tab); |
| 409 EXPECT_TRUE(chrome::search::IsInstantNTP(active_tab)); | 461 EXPECT_TRUE(chrome::search::IsInstantNTP(active_tab)); |
| 410 } | 462 } |
| 411 | 463 |
| 412 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) { | 464 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) { |
| 413 // Setup Instant. | 465 // Setup Instant. |
| 414 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 466 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 415 FocusOmniboxAndWaitForInstantSupport(); | 467 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 416 | 468 |
| 417 // Explicitly unfocus the omnibox. | 469 // Explicitly unfocus the omnibox. |
| 418 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 470 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 419 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 471 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 420 EXPECT_FALSE(omnibox()->model()->has_focus()); | 472 EXPECT_FALSE(omnibox()->model()->has_focus()); |
| 421 | 473 |
| 422 // Open new tab. Preloaded NTP contents should have been used. | 474 // Open new tab. Preloaded NTP contents should have been used. |
| 423 ui_test_utils::NavigateToURLWithDisposition( | 475 ui_test_utils::NavigateToURLWithDisposition( |
| 424 browser(), | 476 browser(), |
| 425 GURL(chrome::kChromeUINewTabURL), | 477 GURL(chrome::kChromeUINewTabURL), |
| 426 NEW_FOREGROUND_TAB, | 478 NEW_FOREGROUND_TAB, |
| 427 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 479 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 428 | 480 |
| 429 // Omnibox should have focus. | 481 // Omnibox should have focus. |
| 430 EXPECT_TRUE(omnibox()->model()->has_focus()); | 482 EXPECT_TRUE(omnibox()->model()->has_focus()); |
| 431 } | 483 } |
| 432 | 484 |
| 433 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) { | 485 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) { |
| 434 // Setup Instant. | 486 // Setup Instant. |
| 435 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 487 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 436 FocusOmniboxAndWaitForInstantSupport(); | 488 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 437 | 489 |
| 438 // Open new tab. Preloaded NTP contents should have been used. | 490 // Open new tab. Preloaded NTP contents should have been used. |
| 439 ui_test_utils::NavigateToURLWithDisposition( | 491 ui_test_utils::NavigateToURLWithDisposition( |
| 440 browser(), | 492 browser(), |
| 441 GURL(chrome::kChromeUINewTabURL), | 493 GURL(chrome::kChromeUINewTabURL), |
| 442 CURRENT_TAB, | 494 CURRENT_TAB, |
| 443 ui_test_utils::BROWSER_TEST_NONE); | 495 ui_test_utils::BROWSER_TEST_NONE); |
| 444 | 496 |
| 445 // Omnibox should be empty. | 497 // Omnibox should be empty. |
| 446 EXPECT_TRUE(omnibox()->GetText().empty()); | 498 EXPECT_TRUE(omnibox()->GetText().empty()); |
| 447 } | 499 } |
| 448 | 500 |
| 449 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoFaviconOnNewTabPage) { | 501 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. |
| 502 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NoFaviconOnNewTabPage) { |
| 450 // Setup Instant. | 503 // Setup Instant. |
| 451 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 504 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 452 FocusOmniboxAndWaitForInstantSupport(); | 505 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 453 | 506 |
| 454 // Open new tab. Preloaded NTP contents should have been used. | 507 // Open new tab. Preloaded NTP contents should have been used. |
| 455 ui_test_utils::NavigateToURLWithDisposition( | 508 ui_test_utils::NavigateToURLWithDisposition( |
| 456 browser(), | 509 browser(), |
| 457 GURL(chrome::kChromeUINewTabURL), | 510 GURL(chrome::kChromeUINewTabURL), |
| 458 CURRENT_TAB, | 511 CURRENT_TAB, |
| 459 ui_test_utils::BROWSER_TEST_NONE); | 512 ui_test_utils::BROWSER_TEST_NONE); |
| 460 | 513 |
| 461 // No favicon should be shown. | 514 // No favicon should be shown. |
| 462 content::WebContents* active_tab = | 515 content::WebContents* active_tab = |
| 463 browser()->tab_strip_model()->GetActiveWebContents(); | 516 browser()->tab_strip_model()->GetActiveWebContents(); |
| 464 FaviconTabHelper* favicon_tab_helper = | 517 FaviconTabHelper* favicon_tab_helper = |
| 465 FaviconTabHelper::FromWebContents(active_tab); | 518 FaviconTabHelper::FromWebContents(active_tab); |
| 466 EXPECT_FALSE(favicon_tab_helper->ShouldDisplayFavicon()); | 519 EXPECT_FALSE(favicon_tab_helper->ShouldDisplayFavicon()); |
| 467 | 520 |
| 468 // Favicon should be shown off the NTP. | 521 // Favicon should be shown off the NTP. |
| 469 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 522 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 470 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 523 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 471 favicon_tab_helper = FaviconTabHelper::FromWebContents(active_tab); | 524 favicon_tab_helper = FaviconTabHelper::FromWebContents(active_tab); |
| 472 EXPECT_TRUE(favicon_tab_helper->ShouldDisplayFavicon()); | 525 EXPECT_TRUE(favicon_tab_helper->ShouldDisplayFavicon()); |
| 473 } | 526 } |
| 474 | 527 |
| 475 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputOnNTPDoesntShowOverlay) { | 528 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputOnNTPDoesntShowOverlay) { |
| 476 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 529 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 477 | 530 |
| 478 // Focus omnibox and confirm overlay isn't shown. | 531 // Focus omnibox and confirm overlay isn't shown. |
| 479 FocusOmniboxAndWaitForInstantSupport(); | 532 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 480 content::WebContents* overlay = instant()->GetOverlayContents(); | 533 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 481 EXPECT_TRUE(overlay); | 534 EXPECT_TRUE(overlay); |
| 482 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 535 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 483 EXPECT_TRUE(instant()->model()->mode().is_default()); | 536 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 484 | 537 |
| 485 // Navigate to the NTP. | 538 // Navigate to the NTP. |
| 486 ui_test_utils::NavigateToURLWithDisposition( | 539 ui_test_utils::NavigateToURLWithDisposition( |
| 487 browser(), | 540 browser(), |
| 488 GURL(chrome::kChromeUINewTabURL), | 541 GURL(chrome::kChromeUINewTabURL), |
| 489 CURRENT_TAB, | 542 CURRENT_TAB, |
| 490 ui_test_utils::BROWSER_TEST_NONE); | 543 ui_test_utils::BROWSER_TEST_NONE); |
| 491 | 544 |
| 492 // Typing in the omnibox should not show the overlay. | 545 // Typing in the omnibox should not show the overlay. |
| 493 SetOmniboxText("query"); | 546 SetOmniboxText("query"); |
| 494 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 547 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 495 EXPECT_TRUE(instant()->model()->mode().is_default()); | 548 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 496 } | 549 } |
| 497 | 550 |
| 498 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) { | 551 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) { |
| 499 // Prior to setup, Instant has an overlay with a failed "google.com" load in | 552 // Prior to setup, Instant has an overlay with a failed "google.com" load in |
| 500 // it, which is rendered in the dedicated Instant renderer process. | 553 // it, which is rendered in the dedicated Instant renderer process. |
| 501 // | 554 // |
| 502 // TODO(sreeram): Fix this up when we stop doing crazy things on init. | 555 // TODO(sreeram): Fix this up when we stop doing crazy things on init. |
| 503 InstantService* instant_service = | 556 InstantService* instant_service = |
| 504 InstantServiceFactory::GetForProfile(browser()->profile()); | 557 InstantServiceFactory::GetForProfile(browser()->profile()); |
| 505 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 558 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 506 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); | 559 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); |
| 507 | 560 |
| 508 // Setup Instant. | 561 // Setup Instant. |
| 509 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 562 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 510 FocusOmniboxAndWaitForInstantSupport(); | 563 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 511 | 564 |
| 512 // The registered Instant render process should still exist. | 565 // The registered Instant render process should still exist. |
| 513 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); | 566 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); |
| 514 | 567 |
| 515 // And the Instant overlay and ntp should live inside it. | 568 // And the Instant overlay and ntp should live inside it. |
| 516 content::WebContents* overlay = instant()->GetOverlayContents(); | 569 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 517 EXPECT_TRUE(instant_service->IsInstantProcess( | 570 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 518 overlay->GetRenderProcessHost()->GetID())); | 571 overlay->GetRenderProcessHost()->GetID())); |
| 519 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 572 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 520 EXPECT_TRUE(instant_service->IsInstantProcess( | 573 EXPECT_TRUE(instant_service->IsInstantProcess( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 536 EXPECT_FALSE(instant_service->IsInstantProcess( | 589 EXPECT_FALSE(instant_service->IsInstantProcess( |
| 537 active_tab->GetRenderProcessHost()->GetID())); | 590 active_tab->GetRenderProcessHost()->GetID())); |
| 538 } | 591 } |
| 539 | 592 |
| 540 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in | 593 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in |
| 541 // a tab uses a new BrowsingInstance, to avoid conflicts in the | 594 // a tab uses a new BrowsingInstance, to avoid conflicts in the |
| 542 // NavigationController. | 595 // NavigationController. |
| 543 // Flaky: http://crbug.com/177516 | 596 // Flaky: http://crbug.com/177516 |
| 544 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { | 597 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { |
| 545 // Setup Instant. | 598 // Setup Instant. |
| 546 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 599 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 547 FocusOmniboxAndWaitForInstantSupport(); | 600 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 548 | 601 |
| 549 // Check that the uncommited ntp page and uncommited overlay have unrelated | 602 // Check that the uncommited ntp page and uncommited overlay have unrelated |
| 550 // site instances. | 603 // site instances. |
| 551 // TODO(sreeram): |ntp_| is going away, so this check can be removed in the | 604 // TODO(sreeram): |ntp_| is going away, so this check can be removed in the |
| 552 // future. | 605 // future. |
| 553 content::WebContents* overlay = instant()->GetOverlayContents(); | 606 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 554 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 607 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 555 EXPECT_FALSE(overlay->GetSiteInstance()->IsRelatedSiteInstance( | 608 EXPECT_FALSE(overlay->GetSiteInstance()->IsRelatedSiteInstance( |
| 556 ntp_contents->GetSiteInstance())); | 609 ntp_contents->GetSiteInstance())); |
| 557 | 610 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 581 EXPECT_NE(first_active_tab, second_active_tab); | 634 EXPECT_NE(first_active_tab, second_active_tab); |
| 582 scoped_refptr<content::SiteInstance> second_site_instance = | 635 scoped_refptr<content::SiteInstance> second_site_instance = |
| 583 second_active_tab->GetSiteInstance(); | 636 second_active_tab->GetSiteInstance(); |
| 584 EXPECT_NE(first_site_instance, second_site_instance); | 637 EXPECT_NE(first_site_instance, second_site_instance); |
| 585 EXPECT_FALSE(first_site_instance->IsRelatedSiteInstance( | 638 EXPECT_FALSE(first_site_instance->IsRelatedSiteInstance( |
| 586 second_site_instance)); | 639 second_site_instance)); |
| 587 } | 640 } |
| 588 | 641 |
| 589 // Tests that suggestions are sanity checked. | 642 // Tests that suggestions are sanity checked. |
| 590 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) { | 643 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) { |
| 591 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 644 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 592 FocusOmniboxAndWaitForInstantSupport(); | 645 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 593 | 646 |
| 594 // Do not set gray text that is not a suffix of the query. | 647 // Do not set gray text that is not a suffix of the query. |
| 595 EXPECT_TRUE(ExecuteScript("behavior = 2")); | 648 EXPECT_TRUE(ExecuteScript("behavior = 2")); |
| 596 EXPECT_TRUE(ExecuteScript("suggestion = 'potato'")); | 649 EXPECT_TRUE(ExecuteScript("suggestion = 'potato'")); |
| 597 SetOmniboxTextAndWaitForOverlayToShow("query"); | 650 SetOmniboxTextAndWaitForOverlayToShow("query"); |
| 598 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); | 651 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); |
| 599 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); | 652 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); |
| 600 | 653 |
| 601 omnibox()->RevertAll(); | 654 omnibox()->RevertAll(); |
| 602 | 655 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 // omnibox text rather than using the supplied suggestion text. | 687 // omnibox text rather than using the supplied suggestion text. |
| 635 EXPECT_TRUE(ExecuteScript("behavior = 1")); | 688 EXPECT_TRUE(ExecuteScript("behavior = 1")); |
| 636 EXPECT_TRUE(ExecuteScript("suggestion = 'www.example.com/q'")); | 689 EXPECT_TRUE(ExecuteScript("suggestion = 'www.example.com/q'")); |
| 637 SetOmniboxText("www.example.com/q"); | 690 SetOmniboxText("www.example.com/q"); |
| 638 omnibox()->OnBeforePossibleChange(); | 691 omnibox()->OnBeforePossibleChange(); |
| 639 SetOmniboxText("www.example.com/"); | 692 SetOmniboxText("www.example.com/"); |
| 640 omnibox()->OnAfterPossibleChange(); | 693 omnibox()->OnAfterPossibleChange(); |
| 641 EXPECT_EQ(ASCIIToUTF16("www.example.com/"), omnibox()->GetText()); | 694 EXPECT_EQ(ASCIIToUTF16("www.example.com/"), omnibox()->GetText()); |
| 642 } | 695 } |
| 643 | 696 |
| 644 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MostVisited) { | 697 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. |
| 698 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_MostVisited) { |
| 645 content::WindowedNotificationObserver observer( | 699 content::WindowedNotificationObserver observer( |
| 646 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, | 700 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, |
| 647 content::NotificationService::AllSources()); | 701 content::NotificationService::AllSources()); |
| 648 // Initialize Instant. | 702 // Initialize Instant. |
| 649 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 703 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 650 FocusOmniboxAndWaitForInstantSupport(); | 704 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 651 | 705 |
| 652 // Get a handle to the NTP and the current state of the JS. | 706 // Get a handle to the NTP and the current state of the JS. |
| 653 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 707 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 654 content::WebContents* overlay = instant()->ntp_->contents(); | 708 content::WebContents* overlay = instant()->ntp_->contents(); |
| 655 EXPECT_TRUE(overlay); | 709 EXPECT_TRUE(overlay); |
| 656 EXPECT_TRUE(UpdateSearchState(overlay)); | 710 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 657 | 711 |
| 658 // Wait for most visited data to be ready, if necessary. | 712 // Wait for most visited data to be ready, if necessary. |
| 659 if (on_most_visited_change_calls_ == 0) { | 713 if (on_most_visited_change_calls_ == 0) { |
| 660 observer.Wait(); | 714 observer.Wait(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 EXPECT_TRUE(ExecuteScript(stream.str())); | 778 EXPECT_TRUE(ExecuteScript(stream.str())); |
| 725 observer.Wait(); | 779 observer.Wait(); |
| 726 | 780 |
| 727 // Update Most Visited state. | 781 // Update Most Visited state. |
| 728 EXPECT_TRUE(UpdateSearchState(overlay)); | 782 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 729 | 783 |
| 730 // Make sure we have the same number of items as before. | 784 // Make sure we have the same number of items as before. |
| 731 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); | 785 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); |
| 732 } | 786 } |
| 733 | 787 |
| 788 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { |
| 789 InstallThemeSource(); |
| 790 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); |
| 791 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 792 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 793 |
| 794 // The "Instant" New Tab should have access to chrome-search: scheme but not |
| 795 // chrome: scheme. |
| 796 ui_test_utils::NavigateToURLWithDisposition( |
| 797 browser(), |
| 798 GURL(chrome::kChromeUINewTabURL), |
| 799 NEW_FOREGROUND_TAB, |
| 800 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 801 |
| 802 content::RenderViewHost* rvh = |
| 803 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 804 |
| 805 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); |
| 806 const std::string search_url( |
| 807 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); |
| 808 bool loaded = false; |
| 809 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); |
| 810 EXPECT_FALSE(loaded) << chrome_url; |
| 811 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); |
| 812 EXPECT_TRUE(loaded) << search_url; |
| 813 } |
| 814 |
| 815 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. |
| 816 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_FaviconAccess) { |
| 817 // Create a favicon. |
| 818 history::TopSites* top_sites = browser()->profile()->GetTopSites(); |
| 819 GURL url("http://www.google.com/foo.html"); |
| 820 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); |
| 821 ThumbnailScore high_score(0.0, true, true, base::Time::Now()); |
| 822 EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score)); |
| 823 |
| 824 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 825 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 826 |
| 827 // The "Instant" New Tab should have access to chrome-search: scheme but not |
| 828 // chrome: scheme. |
| 829 ui_test_utils::NavigateToURLWithDisposition( |
| 830 browser(), |
| 831 GURL(chrome::kChromeUINewTabURL), |
| 832 NEW_FOREGROUND_TAB, |
| 833 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 834 |
| 835 content::RenderViewHost* rvh = |
| 836 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 837 |
| 838 // Get the favicons. |
| 839 const std::string chrome_favicon_url( |
| 840 "chrome://favicon/largest/http://www.google.com/foo.html"); |
| 841 const std::string search_favicon_url( |
| 842 "chrome-search://favicon/largest/http://www.google.com/foo.html"); |
| 843 bool loaded = false; |
| 844 ASSERT_TRUE(LoadImage(rvh, chrome_favicon_url, &loaded)); |
| 845 EXPECT_FALSE(loaded) << chrome_favicon_url; |
| 846 ASSERT_TRUE(LoadImage(rvh, search_favicon_url, &loaded)); |
| 847 EXPECT_TRUE(loaded) << search_favicon_url; |
| 848 } |
| 849 |
| 850 // WebUIBindings should never be enabled on ANY Instant web contents. |
| 851 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnNTP) { |
| 852 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 853 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 854 |
| 855 ui_test_utils::NavigateToURLWithDisposition( |
| 856 browser(), |
| 857 GURL(chrome::kChromeUINewTabURL), |
| 858 NEW_FOREGROUND_TAB, |
| 859 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 860 const content::WebContents* tab = |
| 861 browser()->tab_strip_model()->GetActiveWebContents(); |
| 862 |
| 863 // Instant-provided NTP should not have any bindings enabled. |
| 864 EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings()); |
| 865 } |
| 866 |
| 867 // WebUIBindings should never be enabled on ANY Instant web contents. |
| 868 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnPreview) { |
| 869 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 870 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 871 |
| 872 // Typing in the omnibox shows the overlay. |
| 873 SetOmniboxTextAndWaitForOverlayToShow("query"); |
| 874 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 875 content::WebContents* preview = instant()->GetOverlayContents(); |
| 876 ASSERT_NE(static_cast<content::WebContents*>(NULL), preview); |
| 877 |
| 878 // Instant preview should not have any bindings enabled. |
| 879 EXPECT_EQ(0, preview->GetRenderViewHost()->GetEnabledBindings()); |
| 880 } |
| 881 |
| 882 // WebUIBindings should never be enabled on ANY Instant web contents. |
| 883 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnResults) { |
| 884 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 885 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 886 |
| 887 // Typing in the omnibox shows the overlay. |
| 888 SetOmniboxTextAndWaitForOverlayToShow("query"); |
| 889 content::WebContents* preview = instant()->GetOverlayContents(); |
| 890 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 891 // Commit the search by pressing Enter. |
| 892 browser()->window()->GetLocationBar()->AcceptInput(); |
| 893 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 894 const content::WebContents* tab = |
| 895 browser()->tab_strip_model()->GetActiveWebContents(); |
| 896 EXPECT_EQ(preview, tab); |
| 897 |
| 898 // The commited Instant page should not have any bindings enabled. |
| 899 EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings()); |
| 900 } |
| 901 |
| 734 // Only implemented in Views and Mac currently: http://crbug.com/164723 | 902 // Only implemented in Views and Mac currently: http://crbug.com/164723 |
| 735 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) | 903 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) |
| 736 #define MAYBE_HomeButtonAffectsMargin HomeButtonAffectsMargin | 904 #define MAYBE_HomeButtonAffectsMargin HomeButtonAffectsMargin |
| 737 #else | 905 #else |
| 738 #define MAYBE_HomeButtonAffectsMargin DISABLED_HomeButtonAffectsMargin | 906 #define MAYBE_HomeButtonAffectsMargin DISABLED_HomeButtonAffectsMargin |
| 739 #endif | 907 #endif |
| 740 // Check that toggling the state of the home button changes the start-edge | 908 // Check that toggling the state of the home button changes the start-edge |
| 741 // margin and width. | 909 // margin and width. |
| 742 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_HomeButtonAffectsMargin) { | 910 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_HomeButtonAffectsMargin) { |
| 743 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 911 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 744 | 912 |
| 745 // Get the current value of the start-edge margin and width. | 913 // Get the current value of the start-edge margin and width. |
| 746 int start_margin; | 914 int start_margin; |
| 747 int width; | 915 int width; |
| 748 content::WebContents* overlay = instant()->GetOverlayContents(); | 916 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 749 EXPECT_TRUE(GetIntFromJS(overlay, "chrome.searchBox.startMargin", | 917 EXPECT_TRUE(GetIntFromJS(overlay, "chrome.searchBox.startMargin", |
| 750 &start_margin)); | 918 &start_margin)); |
| 751 EXPECT_TRUE(GetIntFromJS(overlay, "chrome.searchBox.width", &width)); | 919 EXPECT_TRUE(GetIntFromJS(overlay, "chrome.searchBox.width", &width)); |
| 752 | 920 |
| 753 // Toggle the home button visibility pref. | 921 // Toggle the home button visibility pref. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 770 #if defined(OS_MACOSX) | 938 #if defined(OS_MACOSX) |
| 771 #define MAYBE_CommitWhenFocusLostInFullHeight \ | 939 #define MAYBE_CommitWhenFocusLostInFullHeight \ |
| 772 DISABLED_CommitWhenFocusLostInFullHeight | 940 DISABLED_CommitWhenFocusLostInFullHeight |
| 773 #else | 941 #else |
| 774 #define MAYBE_CommitWhenFocusLostInFullHeight CommitWhenFocusLostInFullHeight | 942 #define MAYBE_CommitWhenFocusLostInFullHeight CommitWhenFocusLostInFullHeight |
| 775 #endif | 943 #endif |
| 776 // Test that the overlay is committed when the omnibox loses focus when it is | 944 // Test that the overlay is committed when the omnibox loses focus when it is |
| 777 // shown at 100% height. | 945 // shown at 100% height. |
| 778 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 946 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 779 MAYBE_CommitWhenFocusLostInFullHeight) { | 947 MAYBE_CommitWhenFocusLostInFullHeight) { |
| 780 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 948 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 781 | 949 |
| 782 // Focus omnibox and confirm overlay isn't shown. | 950 // Focus omnibox and confirm overlay isn't shown. |
| 783 FocusOmniboxAndWaitForInstantSupport(); | 951 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 784 content::WebContents* overlay = instant()->GetOverlayContents(); | 952 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 785 EXPECT_TRUE(overlay); | 953 EXPECT_TRUE(overlay); |
| 786 EXPECT_TRUE(instant()->model()->mode().is_default()); | 954 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 787 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 955 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 788 | 956 |
| 789 // Typing in the omnibox should show the overlay. | 957 // Typing in the omnibox should show the overlay. |
| 790 SetOmniboxTextAndWaitForOverlayToShow("query"); | 958 SetOmniboxTextAndWaitForOverlayToShow("query"); |
| 791 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); | 959 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); |
| 792 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 960 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 793 | 961 |
| 794 // Explicitly unfocus the omnibox without triggering a click. Note that this | 962 // Explicitly unfocus the omnibox without triggering a click. Note that this |
| 795 // doesn't actually change the focus state of the omnibox, only what the | 963 // doesn't actually change the focus state of the omnibox, only what the |
| 796 // Instant controller sees it as. | 964 // Instant controller sees it as. |
| 797 omnibox()->model()->OnWillKillFocus(NULL); | 965 omnibox()->model()->OnWillKillFocus(NULL); |
| 798 omnibox()->model()->OnKillFocus(); | 966 omnibox()->model()->OnKillFocus(); |
| 799 | 967 |
| 800 // Confirm that the overlay has been committed. | 968 // Confirm that the overlay has been committed. |
| 801 content::WebContents* active_tab = | 969 content::WebContents* active_tab = |
| 802 browser()->tab_strip_model()->GetActiveWebContents(); | 970 browser()->tab_strip_model()->GetActiveWebContents(); |
| 803 EXPECT_EQ(overlay, active_tab); | 971 EXPECT_EQ(overlay, active_tab); |
| 804 } | 972 } |
| 805 | 973 |
| 806 // Test that the overlay is committed when shown at 100% height without focus | 974 // Test that the overlay is committed when shown at 100% height without focus |
| 807 // in the omnibox. | 975 // in the omnibox. |
| 808 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 976 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 809 CommitWhenShownInFullHeightWithoutFocus) { | 977 CommitWhenShownInFullHeightWithoutFocus) { |
| 810 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 978 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 811 | 979 |
| 812 // Focus omnibox and confirm overlay isn't shown. | 980 // Focus omnibox and confirm overlay isn't shown. |
| 813 FocusOmniboxAndWaitForInstantSupport(); | 981 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 814 content::WebContents* overlay = instant()->GetOverlayContents(); | 982 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 815 EXPECT_TRUE(overlay); | 983 EXPECT_TRUE(overlay); |
| 816 EXPECT_TRUE(instant()->model()->mode().is_default()); | 984 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 817 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 985 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 818 | 986 |
| 819 // Create an observer to wait for the commit. | 987 // Create an observer to wait for the commit. |
| 820 content::WindowedNotificationObserver observer( | 988 content::WindowedNotificationObserver observer( |
| 821 chrome::NOTIFICATION_INSTANT_COMMITTED, | 989 chrome::NOTIFICATION_INSTANT_COMMITTED, |
| 822 content::NotificationService::AllSources()); | 990 content::NotificationService::AllSources()); |
| 823 | 991 |
| 824 // Typing in the omnibox should show the overlay. Don't wait for the overlay | 992 // Typing in the omnibox should show the overlay. Don't wait for the overlay |
| 825 // to show however. | 993 // to show however. |
| 826 SetOmniboxText("query"); | 994 SetOmniboxText("query"); |
| 827 | 995 |
| 828 // Explicitly unfocus the omnibox without triggering a click. Note that this | 996 // Explicitly unfocus the omnibox without triggering a click. Note that this |
| 829 // doesn't actually change the focus state of the omnibox, only what the | 997 // doesn't actually change the focus state of the omnibox, only what the |
| 830 // Instant controller sees it as. | 998 // Instant controller sees it as. |
| 831 omnibox()->model()->OnWillKillFocus(NULL); | 999 omnibox()->model()->OnWillKillFocus(NULL); |
| 832 omnibox()->model()->OnKillFocus(); | 1000 omnibox()->model()->OnKillFocus(); |
| 833 | 1001 |
| 834 // Wait for the overlay to show. | 1002 // Wait for the overlay to show. |
| 835 observer.Wait(); | 1003 observer.Wait(); |
| 836 | 1004 |
| 837 // Confirm that the overlay has been committed. | 1005 // Confirm that the overlay has been committed. |
| 838 content::WebContents* active_tab = | 1006 content::WebContents* active_tab = |
| 839 browser()->tab_strip_model()->GetActiveWebContents(); | 1007 browser()->tab_strip_model()->GetActiveWebContents(); |
| 840 EXPECT_EQ(overlay, active_tab); | 1008 EXPECT_EQ(overlay, active_tab); |
| 841 } | 1009 } |
| OLD | NEW |