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 "chrome/browser/instant/instant_commit_type.h" | 5 #include "chrome/browser/instant/instant_commit_type.h" |
6 #include "chrome/browser/instant/instant_ntp.h" | 6 #include "chrome/browser/instant/instant_ntp.h" |
7 #include "chrome/browser/instant/instant_overlay.h" | 7 #include "chrome/browser/instant/instant_overlay.h" |
8 #include "chrome/browser/instant/instant_service.h" | 8 #include "chrome/browser/instant/instant_service.h" |
9 #include "chrome/browser/instant/instant_service_factory.h" | 9 #include "chrome/browser/instant/instant_service_factory.h" |
10 #include "chrome/browser/instant/instant_test_utils.h" | 10 #include "chrome/browser/instant/instant_test_utils.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 EXPECT_TRUE(preview_tab); | 113 EXPECT_TRUE(preview_tab); |
114 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 114 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
115 EXPECT_TRUE(instant()->model()->mode().is_default()); | 115 EXPECT_TRUE(instant()->model()->mode().is_default()); |
116 | 116 |
117 // Typing in the omnibox should show the overlay. | 117 // Typing in the omnibox should show the overlay. |
118 SetOmniboxTextAndWaitForInstantToShow("query"); | 118 SetOmniboxTextAndWaitForInstantToShow("query"); |
119 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 119 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
120 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 120 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
121 } | 121 } |
122 | 122 |
| 123 // TODO(sreeram): Enable this test once @mathp's CL lands: |
| 124 // https://codereview.chromium.org/12179025/ |
| 125 // |
123 // Test that omnibox text is correctly set when overlay is committed with Enter. | 126 // Test that omnibox text is correctly set when overlay is committed with Enter. |
124 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) { | 127 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 128 DISABLED_OmniboxTextUponEnterCommit) { |
125 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 129 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
126 FocusOmniboxAndWaitForInstantSupport(); | 130 FocusOmniboxAndWaitForInstantSupport(); |
127 | 131 |
128 // The page will autocomplete once we set the omnibox value. | 132 // The page will autocomplete once we set the omnibox value. |
129 EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';")); | 133 EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';")); |
130 | 134 |
131 // Set the text, and wait for suggestions to show up. | 135 // Set the text, and wait for suggestions to show up. |
132 SetOmniboxTextAndWaitForInstantToShow("santa"); | 136 SetOmniboxTextAndWaitForInstantToShow("santa"); |
133 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); | 137 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); |
134 | 138 |
135 // Test that the current suggestion is correctly set. | 139 // Test that the current suggestion is correctly set. |
136 EXPECT_EQ(ASCIIToUTF16(" claus"), omnibox()->GetInstantSuggestion()); | 140 EXPECT_EQ(ASCIIToUTF16(" claus"), omnibox()->GetInstantSuggestion()); |
137 | 141 |
138 // Commit the search by pressing Enter. | 142 // Commit the search by pressing Enter. |
139 browser()->window()->GetLocationBar()->AcceptInput(); | 143 browser()->window()->GetLocationBar()->AcceptInput(); |
140 | 144 |
141 // 'Enter' commits the query as it was typed. | 145 // 'Enter' commits the query as it was typed. |
142 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); | 146 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); |
143 | 147 |
144 // Suggestion should be cleared at this point. | 148 // Suggestion should be cleared at this point. |
145 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); | 149 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); |
146 } | 150 } |
147 | 151 |
| 152 // TODO(sreeram): Enable this test once @mathp's CL lands: |
| 153 // https://codereview.chromium.org/12179025/ |
| 154 // |
148 // Test that omnibox text is correctly set when overlay is committed with focus | 155 // Test that omnibox text is correctly set when overlay is committed with focus |
149 // lost. | 156 // lost. |
150 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) { | 157 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 158 DISABLED_OmniboxTextUponFocusLostCommit) { |
151 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 159 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
152 FocusOmniboxAndWaitForInstantSupport(); | 160 FocusOmniboxAndWaitForInstantSupport(); |
153 | 161 |
154 // Set autocomplete text (grey text). | 162 // Set autocomplete text (grey text). |
155 EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';")); | 163 EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';")); |
156 | 164 |
157 // Set the text, and wait for suggestions to show up. | 165 // Set the text, and wait for suggestions to show up. |
158 SetOmniboxTextAndWaitForInstantToShow("johnny"); | 166 SetOmniboxTextAndWaitForInstantToShow("johnny"); |
159 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); | 167 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); |
160 | 168 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 CURRENT_TAB, | 305 CURRENT_TAB, |
298 ui_test_utils::BROWSER_TEST_NONE); | 306 ui_test_utils::BROWSER_TEST_NONE); |
299 | 307 |
300 // Typing in the omnibox should not show the overlay. | 308 // Typing in the omnibox should not show the overlay. |
301 SetOmniboxText("query"); | 309 SetOmniboxText("query"); |
302 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 310 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
303 EXPECT_TRUE(instant()->model()->mode().is_default()); | 311 EXPECT_TRUE(instant()->model()->mode().is_default()); |
304 } | 312 } |
305 | 313 |
306 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) { | 314 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) { |
307 // Prior to setup no render process is dedicated to Instant. | 315 // Prior to setup, Instant has an overlay with a failed "google.com" load in |
| 316 // it, which is rendered in the dedicated Instant renderer process. |
| 317 // |
| 318 // TODO(sreeram): Fix this up when we stop doing crazy things on init. |
308 InstantService* instant_service = | 319 InstantService* instant_service = |
309 InstantServiceFactory::GetForProfile(browser()->profile()); | 320 InstantServiceFactory::GetForProfile(browser()->profile()); |
310 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 321 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
311 EXPECT_EQ(0, instant_service->GetInstantProcessCount()); | 322 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); |
312 | 323 |
313 // Setup Instant. | 324 // Setup Instant. |
314 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 325 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
315 FocusOmniboxAndWaitForInstantSupport(); | 326 FocusOmniboxAndWaitForInstantSupport(); |
316 | 327 |
317 // Now there should be a registered Instant render process. | 328 // The registered Instant render process should still exist. |
318 EXPECT_LT(0, instant_service->GetInstantProcessCount()); | 329 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); |
319 | 330 |
320 // And the Instant overlay and ntp should live inside it. | 331 // And the Instant overlay and ntp should live inside it. |
321 content::WebContents* preview = instant()->GetPreviewContents(); | 332 content::WebContents* preview = instant()->GetPreviewContents(); |
322 EXPECT_TRUE(instant_service->IsInstantProcess( | 333 EXPECT_TRUE(instant_service->IsInstantProcess( |
323 preview->GetRenderProcessHost()->GetID())); | 334 preview->GetRenderProcessHost()->GetID())); |
324 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 335 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
325 EXPECT_TRUE(instant_service->IsInstantProcess( | 336 EXPECT_TRUE(instant_service->IsInstantProcess( |
326 ntp_contents->GetRenderProcessHost()->GetID())); | 337 ntp_contents->GetRenderProcessHost()->GetID())); |
327 | 338 |
328 // Navigating to the NTP should use the Instant render process. | 339 // Navigating to the NTP should use the Instant render process. |
329 ui_test_utils::NavigateToURLWithDisposition( | 340 ui_test_utils::NavigateToURLWithDisposition( |
330 browser(), | 341 browser(), |
331 GURL(chrome::kChromeUINewTabURL), | 342 GURL(chrome::kChromeUINewTabURL), |
332 CURRENT_TAB, | 343 CURRENT_TAB, |
333 ui_test_utils::BROWSER_TEST_NONE); | 344 ui_test_utils::BROWSER_TEST_NONE); |
334 content::WebContents* active_tab = | 345 content::WebContents* active_tab = |
335 browser()->tab_strip_model()->GetActiveWebContents(); | 346 browser()->tab_strip_model()->GetActiveWebContents(); |
336 EXPECT_TRUE(instant_service->IsInstantProcess( | 347 EXPECT_TRUE(instant_service->IsInstantProcess( |
337 active_tab->GetRenderProcessHost()->GetID())); | 348 active_tab->GetRenderProcessHost()->GetID())); |
338 | 349 |
339 // Navigating elsewhere should not use the Instant render process. | 350 // Navigating elsewhere should not use the Instant render process. |
340 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 351 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
341 EXPECT_FALSE(instant_service->IsInstantProcess( | 352 EXPECT_FALSE(instant_service->IsInstantProcess( |
342 active_tab->GetRenderProcessHost()->GetID())); | 353 active_tab->GetRenderProcessHost()->GetID())); |
343 } | 354 } |
OLD | NEW |