OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/content_settings/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
6 #include "chrome/browser/history/history_service_factory.h" | 6 #include "chrome/browser/history/history_service_factory.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/search/instant_service.h" | 8 #include "chrome/browser/search/instant_service.h" |
9 #include "chrome/browser/search/instant_service_factory.h" | 9 #include "chrome/browser/search/instant_service_factory.h" |
10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Unfocusing and refocusing the omnibox should also preserve the overlay. | 95 // Unfocusing and refocusing the omnibox should also preserve the overlay. |
96 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 96 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
97 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 97 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
98 | 98 |
99 FocusOmnibox(); | 99 FocusOmnibox(); |
100 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 100 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
101 | 101 |
102 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 102 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
103 | 103 |
104 // Doing a search should also use the same preloaded page. | 104 // Doing a search should also use the same preloaded page. |
105 SetOmniboxTextAndWaitForOverlayToShow("query"); | 105 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
106 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 106 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
107 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 107 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
108 } | 108 } |
109 | 109 |
110 // Flakes on Windows and Mac: http://crbug.com/170677 | 110 // Flakes on Windows and Mac: http://crbug.com/170677 |
111 #if defined(OS_WIN) || defined(OS_MACOSX) | 111 #if defined(OS_WIN) || defined(OS_MACOSX) |
112 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent | 112 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent |
113 #else | 113 #else |
114 #define MAYBE_OnChangeEvent OnChangeEvent | 114 #define MAYBE_OnChangeEvent OnChangeEvent |
115 #endif | 115 #endif |
116 // Test that the onchange event is dispatched upon typing in the omnibox. | 116 // Test that the onchange event is dispatched upon typing in the omnibox. |
117 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnChangeEvent) { | 117 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnChangeEvent) { |
118 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 118 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
119 FocusOmniboxAndWaitForInstantSupport(); | 119 FocusOmniboxAndWaitForInstantSupport(); |
120 | 120 |
121 // Use the Instant page as the active tab, so we can exploit its visibility | 121 // Use the Instant page as the active tab, so we can exploit its visibility |
122 // handler to check visibility transitions. | 122 // handler to check visibility transitions. |
123 ui_test_utils::NavigateToURL(browser(), instant_url()); | 123 ui_test_utils::NavigateToURL(browser(), instant_url()); |
124 content::WebContents* active_tab = | 124 content::WebContents* active_tab = |
125 browser()->tab_strip_model()->GetActiveWebContents(); | 125 browser()->tab_strip_model()->GetActiveWebContents(); |
126 | 126 |
127 int active_tab_onvisibilitycalls = -1; | 127 int active_tab_onvisibilitycalls = -1; |
128 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", | 128 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", |
129 &active_tab_onvisibilitycalls)); | 129 &active_tab_onvisibilitycalls)); |
130 EXPECT_EQ(0, active_tab_onvisibilitycalls); | 130 EXPECT_EQ(0, active_tab_onvisibilitycalls); |
131 | 131 |
132 // Typing "query" into the omnibox causes one or more onchange events. The | 132 // Typing "query" into the omnibox causes one or more onchange events. The |
133 // page suggested "query suggestion" is inline autocompleted into the omnibox, | 133 // page suggested "query suggestion" is inline autocompleted into the omnibox, |
134 // causing another onchange event. | 134 // causing another onchange event. |
135 SetOmniboxTextAndWaitForOverlayToShow("query"); | 135 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
136 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 136 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
137 int min_onchangecalls = 2; | 137 int min_onchangecalls = 2; |
138 | 138 |
139 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 139 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
140 EXPECT_LE(min_onchangecalls, onchangecalls_); | 140 EXPECT_LE(min_onchangecalls, onchangecalls_); |
141 min_onchangecalls = onchangecalls_; | 141 min_onchangecalls = onchangecalls_; |
142 | 142 |
143 // Change the query and confirm more onchange events are sent. | 143 // Change the query and confirm more onchange events are sent. |
144 SetOmniboxText("search"); | 144 SetOmniboxText("search"); |
145 ++min_onchangecalls; | 145 ++min_onchangecalls; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 EXPECT_TRUE(verbatim_); | 213 EXPECT_TRUE(verbatim_); |
214 EXPECT_EQ(1, onsubmitcalls_); | 214 EXPECT_EQ(1, onsubmitcalls_); |
215 EXPECT_EQ(1, onvisibilitycalls_); | 215 EXPECT_EQ(1, onvisibilitycalls_); |
216 } | 216 } |
217 | 217 |
218 // Test that the oncancel event is dispatched upon clicking on the overlay. | 218 // Test that the oncancel event is dispatched upon clicking on the overlay. |
219 IN_PROC_BROWSER_TEST_F(InstantTest, OnCancelEvent) { | 219 IN_PROC_BROWSER_TEST_F(InstantTest, OnCancelEvent) { |
220 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 220 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
221 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 221 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
222 FocusOmniboxAndWaitForInstantSupport(); | 222 FocusOmniboxAndWaitForInstantSupport(); |
223 SetOmniboxTextAndWaitForOverlayToShow("search"); | 223 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
224 | 224 |
225 // Stash a reference to the overlay, so we can refer to it after commit. | 225 // Stash a reference to the overlay, so we can refer to it after commit. |
226 content::WebContents* overlay = instant()->GetOverlayContents(); | 226 content::WebContents* overlay = instant()->GetOverlayContents(); |
227 EXPECT_TRUE(overlay); | 227 EXPECT_TRUE(overlay); |
228 | 228 |
229 // The state of the searchbox before the commit. | 229 // The state of the searchbox before the commit. |
230 EXPECT_TRUE(UpdateSearchState(overlay)); | 230 EXPECT_TRUE(UpdateSearchState(overlay)); |
231 EXPECT_EQ("search", value_); | 231 EXPECT_EQ("search", value_); |
232 EXPECT_FALSE(verbatim_); | 232 EXPECT_FALSE(verbatim_); |
233 EXPECT_EQ(0, oncancelcalls_); | 233 EXPECT_EQ(0, oncancelcalls_); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 281 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
282 | 282 |
283 FocusOmniboxAndWaitForInstantSupport(); | 283 FocusOmniboxAndWaitForInstantSupport(); |
284 | 284 |
285 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 285 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
286 EXPECT_EQ(0, onresizecalls_); | 286 EXPECT_EQ(0, onresizecalls_); |
287 EXPECT_EQ(0, height_); | 287 EXPECT_EQ(0, height_); |
288 | 288 |
289 // Type a query into the omnibox. This should cause an onresize() event, with | 289 // Type a query into the omnibox. This should cause an onresize() event, with |
290 // a valid (non-zero) height. | 290 // a valid (non-zero) height. |
291 SetOmniboxTextAndWaitForOverlayToShow("search"); | 291 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
292 | 292 |
293 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 293 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
294 EXPECT_EQ(1, onresizecalls_); | 294 EXPECT_EQ(1, onresizecalls_); |
295 EXPECT_LT(0, height_); | 295 EXPECT_LT(0, height_); |
296 } | 296 } |
297 | 297 |
298 // Test that the INSTANT_COMPLETE_NOW behavior works as expected. | 298 // Test that the INSTANT_COMPLETE_NOW behavior works as expected. |
299 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) { | 299 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) { |
300 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 300 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
301 FocusOmniboxAndWaitForInstantSupport(); | 301 FocusOmniboxAndWaitForInstantSupport(); |
302 | 302 |
303 // Tell the JS to request the given behavior. | 303 // Tell the JS to request the given behavior. |
304 EXPECT_TRUE(ExecuteScript("behavior = 'now'")); | 304 EXPECT_TRUE(ExecuteScript("behavior = 'now'")); |
305 | 305 |
306 // Type a query, causing the hardcoded "query suggestion" to be returned. | 306 // Type a query, causing the hardcoded "query suggestion" to be returned. |
307 SetOmniboxTextAndWaitForOverlayToShow("query"); | 307 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
308 | 308 |
309 // Get what's showing in the omnibox, and what's highlighted. | 309 // Get what's showing in the omnibox, and what's highlighted. |
310 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 310 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
311 EXPECT_EQ(ASCIIToUTF16(" suggestion"), GetBlueText()); | 311 EXPECT_EQ(ASCIIToUTF16(" suggestion"), GetBlueText()); |
312 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 312 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
313 } | 313 } |
314 | 314 |
315 // Test that the INSTANT_COMPLETE_NEVER behavior works as expected. | 315 // Test that the INSTANT_COMPLETE_NEVER behavior works as expected. |
316 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNever) { | 316 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNever) { |
317 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 317 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
318 FocusOmniboxAndWaitForInstantSupport(); | 318 FocusOmniboxAndWaitForInstantSupport(); |
319 | 319 |
320 // Tell the JS to request the given behavior. | 320 // Tell the JS to request the given behavior. |
321 EXPECT_TRUE(ExecuteScript("behavior = 'never'")); | 321 EXPECT_TRUE(ExecuteScript("behavior = 'never'")); |
322 | 322 |
323 // Type a query, causing the hardcoded "query suggestion" to be returned. | 323 // Type a query, causing the hardcoded "query suggestion" to be returned. |
324 SetOmniboxTextAndWaitForOverlayToShow("query"); | 324 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
325 | 325 |
326 // Get what's showing in the omnibox, and what's highlighted. | 326 // Get what's showing in the omnibox, and what's highlighted. |
327 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); | 327 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); |
328 EXPECT_EQ(ASCIIToUTF16(""), GetBlueText()); | 328 EXPECT_EQ(ASCIIToUTF16(""), GetBlueText()); |
329 EXPECT_EQ(ASCIIToUTF16(" suggestion"), GetGrayText()); | 329 EXPECT_EQ(ASCIIToUTF16(" suggestion"), GetGrayText()); |
330 } | 330 } |
331 | 331 |
332 // Test that a valid suggestion is accepted. | 332 // Test that a valid suggestion is accepted. |
333 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsValidObject) { | 333 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsValidObject) { |
334 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 334 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
335 FocusOmniboxAndWaitForInstantSupport(); | 335 FocusOmniboxAndWaitForInstantSupport(); |
336 | 336 |
337 // Tell the JS to use the given suggestion. | 337 // Tell the JS to use the given suggestion. |
338 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'query completion' } ]")); | 338 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'query completion' } ]")); |
339 | 339 |
340 // Type a query, causing "query completion" to be returned as the suggestion. | 340 // Type a query, causing "query completion" to be returned as the suggestion. |
341 SetOmniboxTextAndWaitForOverlayToShow("query"); | 341 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
342 EXPECT_EQ(ASCIIToUTF16("query completion"), omnibox()->GetText()); | 342 EXPECT_EQ(ASCIIToUTF16("query completion"), omnibox()->GetText()); |
343 } | 343 } |
344 | 344 |
345 // Test that an invalid suggestion is rejected. | 345 // Test that an invalid suggestion is rejected. |
346 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsInvalidObject) { | 346 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsInvalidObject) { |
347 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 347 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
348 FocusOmniboxAndWaitForInstantSupport(); | 348 FocusOmniboxAndWaitForInstantSupport(); |
349 | 349 |
350 // Tell the JS to use an object in an invalid format. | 350 // Tell the JS to use an object in an invalid format. |
351 EXPECT_TRUE(ExecuteScript("suggestion = { value: 'query completion' }")); | 351 EXPECT_TRUE(ExecuteScript("suggestion = { value: 'query completion' }")); |
352 | 352 |
353 // Type a query, but expect no suggestion. | 353 // Type a query, but expect no suggestion. |
354 SetOmniboxTextAndWaitForOverlayToShow("query"); | 354 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
355 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); | 355 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); |
356 } | 356 } |
357 | 357 |
358 // Test that various forms of empty suggestions are rejected. | 358 // Test that various forms of empty suggestions are rejected. |
359 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsEmpty) { | 359 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsEmpty) { |
360 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 360 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
361 FocusOmniboxAndWaitForInstantSupport(); | 361 FocusOmniboxAndWaitForInstantSupport(); |
362 | 362 |
363 EXPECT_TRUE(ExecuteScript("suggestion = {}")); | 363 EXPECT_TRUE(ExecuteScript("suggestion = {}")); |
364 SetOmniboxTextAndWaitForOverlayToShow("query"); | 364 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
365 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); | 365 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); |
366 | 366 |
367 omnibox()->RevertAll(); | 367 omnibox()->RevertAll(); |
368 | 368 |
369 EXPECT_TRUE(ExecuteScript("suggestion = []")); | 369 EXPECT_TRUE(ExecuteScript("suggestion = []")); |
370 SetOmniboxTextAndWaitForOverlayToShow("query sugg"); | 370 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query sugg")); |
371 EXPECT_EQ(ASCIIToUTF16("query sugg"), omnibox()->GetText()); | 371 EXPECT_EQ(ASCIIToUTF16("query sugg"), omnibox()->GetText()); |
372 | 372 |
373 omnibox()->RevertAll(); | 373 omnibox()->RevertAll(); |
374 | 374 |
375 EXPECT_TRUE(ExecuteScript("suggestion = [{}]")); | 375 EXPECT_TRUE(ExecuteScript("suggestion = [{}]")); |
376 SetOmniboxTextAndWaitForOverlayToShow("query suggest"); | 376 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query suggest")); |
377 EXPECT_EQ(ASCIIToUTF16("query suggest"), omnibox()->GetText()); | 377 EXPECT_EQ(ASCIIToUTF16("query suggest"), omnibox()->GetText()); |
378 } | 378 } |
379 | 379 |
380 // Tests that a previous search suggestion is not discarded if it's not stale. | 380 // Tests that a previous search suggestion is not discarded if it's not stale. |
381 IN_PROC_BROWSER_TEST_F(InstantTest, SearchSuggestionIsNotDiscarded) { | 381 IN_PROC_BROWSER_TEST_F(InstantTest, SearchSuggestionIsNotDiscarded) { |
382 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 382 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
383 FocusOmniboxAndWaitForInstantSupport(); | 383 FocusOmniboxAndWaitForInstantSupport(); |
384 | 384 |
385 SetOmniboxTextAndWaitForOverlayToShow("query"); | 385 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
386 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 386 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
387 SetOmniboxText("query sugg"); | 387 SetOmniboxText("query sugg"); |
388 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 388 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
389 } | 389 } |
390 | 390 |
391 // Test that Instant doesn't process URLs. | 391 // Test that Instant doesn't process URLs. |
392 IN_PROC_BROWSER_TEST_F(InstantTest, RejectsURLs) { | 392 IN_PROC_BROWSER_TEST_F(InstantTest, RejectsURLs) { |
393 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 393 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
394 FocusOmniboxAndWaitForInstantSupport(); | 394 FocusOmniboxAndWaitForInstantSupport(); |
395 | 395 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 int min_onchangecalls = 2; | 443 int min_onchangecalls = 2; |
444 | 444 |
445 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 445 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
446 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 446 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
447 EXPECT_TRUE(instant()->model()->mode().is_default()); | 447 EXPECT_TRUE(instant()->model()->mode().is_default()); |
448 EXPECT_EQ("", value_); | 448 EXPECT_EQ("", value_); |
449 EXPECT_LE(min_onchangecalls, onchangecalls_); | 449 EXPECT_LE(min_onchangecalls, onchangecalls_); |
450 min_onchangecalls = onchangecalls_; | 450 min_onchangecalls = onchangecalls_; |
451 | 451 |
452 // Type a search. Instant should show. | 452 // Type a search. Instant should show. |
453 SetOmniboxTextAndWaitForOverlayToShow("search"); | 453 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
454 ++min_onchangecalls; | 454 ++min_onchangecalls; |
455 | 455 |
456 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 456 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
457 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); | 457 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); |
458 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 458 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
459 EXPECT_EQ("search", value_); | 459 EXPECT_EQ("search", value_); |
460 EXPECT_LE(min_onchangecalls, onchangecalls_); | 460 EXPECT_LE(min_onchangecalls, onchangecalls_); |
461 min_onchangecalls = onchangecalls_; | 461 min_onchangecalls = onchangecalls_; |
462 | 462 |
463 // Type another URL. The overlay should be hidden. | 463 // Type another URL. The overlay should be hidden. |
464 SetOmniboxText("http://terrible/terror"); | 464 SetOmniboxText("http://terrible/terror"); |
465 ++min_onchangecalls; | 465 ++min_onchangecalls; |
466 | 466 |
467 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 467 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
468 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 468 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
469 EXPECT_TRUE(instant()->model()->mode().is_default()); | 469 EXPECT_TRUE(instant()->model()->mode().is_default()); |
470 EXPECT_EQ("", value_); | 470 EXPECT_EQ("", value_); |
471 EXPECT_LE(min_onchangecalls, onchangecalls_); | 471 EXPECT_LE(min_onchangecalls, onchangecalls_); |
472 min_onchangecalls = onchangecalls_; | 472 min_onchangecalls = onchangecalls_; |
473 | 473 |
474 // Type the same search as before. | 474 // Type the same search as before. |
475 SetOmniboxTextAndWaitForOverlayToShow("search"); | 475 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
476 min_onchangecalls++; | 476 min_onchangecalls++; |
477 | 477 |
478 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 478 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
479 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); | 479 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); |
480 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 480 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
481 EXPECT_EQ("search", value_); | 481 EXPECT_EQ("search", value_); |
482 EXPECT_LE(min_onchangecalls, onchangecalls_); | 482 EXPECT_LE(min_onchangecalls, onchangecalls_); |
483 min_onchangecalls = onchangecalls_; | 483 min_onchangecalls = onchangecalls_; |
484 | 484 |
485 // Revert the omnibox. | 485 // Revert the omnibox. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 528 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
529 EXPECT_TRUE(instant()->model()->mode().is_default()); | 529 EXPECT_TRUE(instant()->model()->mode().is_default()); |
530 } | 530 } |
531 | 531 |
532 // Test that Instant can't be fooled into committing a URL. | 532 // Test that Instant can't be fooled into committing a URL. |
533 IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsTwo) { | 533 IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsTwo) { |
534 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 534 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
535 FocusOmniboxAndWaitForInstantSupport(); | 535 FocusOmniboxAndWaitForInstantSupport(); |
536 | 536 |
537 // Type a query. This causes the overlay to be shown. | 537 // Type a query. This causes the overlay to be shown. |
538 SetOmniboxTextAndWaitForOverlayToShow("query"); | 538 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
539 | 539 |
540 content::WebContents* overlay = instant()->GetOverlayContents(); | 540 content::WebContents* overlay = instant()->GetOverlayContents(); |
541 EXPECT_TRUE(overlay); | 541 EXPECT_TRUE(overlay); |
542 | 542 |
543 // Type a URL. This causes the overlay to be hidden. | 543 // Type a URL. This causes the overlay to be hidden. |
544 SetOmniboxText("http://hideous/zippleback"); | 544 SetOmniboxText("http://hideous/zippleback"); |
545 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 545 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
546 EXPECT_TRUE(instant()->model()->mode().is_default()); | 546 EXPECT_TRUE(instant()->model()->mode().is_default()); |
547 | 547 |
548 // Pretend the omnibox got focus. It already had focus, so we are just trying | 548 // Pretend the omnibox got focus. It already had focus, so we are just trying |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 | 595 |
596 content::WebContents* active_tab = | 596 content::WebContents* active_tab = |
597 browser()->tab_strip_model()->GetActiveWebContents(); | 597 browser()->tab_strip_model()->GetActiveWebContents(); |
598 content::WebContents* overlay = instant()->GetOverlayContents(); | 598 content::WebContents* overlay = instant()->GetOverlayContents(); |
599 | 599 |
600 // Inititally, the active tab is showing; the overlay is not. | 600 // Inititally, the active tab is showing; the overlay is not. |
601 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); | 601 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
602 EXPECT_TRUE(CheckVisibilityIs(overlay, false)); | 602 EXPECT_TRUE(CheckVisibilityIs(overlay, false)); |
603 | 603 |
604 // Type a query and wait for Instant to show. | 604 // Type a query and wait for Instant to show. |
605 SetOmniboxTextAndWaitForOverlayToShow("query"); | 605 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
606 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); | 606 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
607 EXPECT_TRUE(CheckVisibilityIs(overlay, true)); | 607 EXPECT_TRUE(CheckVisibilityIs(overlay, true)); |
608 | 608 |
609 // Deleting the omnibox text should hide the overlay. | 609 // Deleting the omnibox text should hide the overlay. |
610 SetOmniboxText(std::string()); | 610 SetOmniboxText(std::string()); |
611 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); | 611 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
612 EXPECT_TRUE(CheckVisibilityIs(overlay, false)); | 612 EXPECT_TRUE(CheckVisibilityIs(overlay, false)); |
613 | 613 |
614 // Typing a query should show the overlay again. | 614 // Typing a query should show the overlay again. |
615 SetOmniboxTextAndWaitForOverlayToShow("query"); | 615 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
616 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); | 616 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
617 EXPECT_TRUE(CheckVisibilityIs(overlay, true)); | 617 EXPECT_TRUE(CheckVisibilityIs(overlay, true)); |
618 | 618 |
619 // Commit the overlay. | 619 // Commit the overlay. |
620 browser()->window()->GetLocationBar()->AcceptInput(); | 620 browser()->window()->GetLocationBar()->AcceptInput(); |
621 EXPECT_EQ(overlay, browser()->tab_strip_model()->GetActiveWebContents()); | 621 EXPECT_EQ(overlay, browser()->tab_strip_model()->GetActiveWebContents()); |
622 EXPECT_TRUE(CheckVisibilityIs(overlay, true)); | 622 EXPECT_TRUE(CheckVisibilityIs(overlay, true)); |
623 } | 623 } |
624 | 624 |
625 // Test that the task manager identifies Instant's overlay correctly. | 625 // Test that the task manager identifies Instant's overlay correctly. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 // |instant_url| is the URL Instant loads. |search_url| is the fake URL we | 683 // |instant_url| is the URL Instant loads. |search_url| is the fake URL we |
684 // enter into history for search terms extraction to work correctly. | 684 // enter into history for search terms extraction to work correctly. |
685 std::string search_url = template_url->url_ref().ReplaceSearchTerms( | 685 std::string search_url = template_url->url_ref().ReplaceSearchTerms( |
686 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("search"))); | 686 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("search"))); |
687 | 687 |
688 HistoryService* history = HistoryServiceFactory::GetForProfile( | 688 HistoryService* history = HistoryServiceFactory::GetForProfile( |
689 browser()->profile(), Profile::EXPLICIT_ACCESS); | 689 browser()->profile(), Profile::EXPLICIT_ACCESS); |
690 ui_test_utils::WaitForHistoryToLoad(history); | 690 ui_test_utils::WaitForHistoryToLoad(history); |
691 | 691 |
692 // Perform a search. | 692 // Perform a search. |
693 SetOmniboxTextAndWaitForOverlayToShow("search"); | 693 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
694 | 694 |
695 // Commit the search. | 695 // Commit the search. |
696 browser()->window()->GetLocationBar()->AcceptInput(); | 696 browser()->window()->GetLocationBar()->AcceptInput(); |
697 | 697 |
698 bool found = false; | 698 bool found = false; |
699 CancelableRequestConsumer consumer; | 699 CancelableRequestConsumer consumer; |
700 | 700 |
701 // The fake search URL should be in history. | 701 // The fake search URL should be in history. |
702 base::RunLoop run_loop1; | 702 base::RunLoop run_loop1; |
703 history->QueryURL(GURL(search_url), false, &consumer, | 703 history->QueryURL(GURL(search_url), false, &consumer, |
(...skipping 24 matching lines...) Expand all Loading... |
728 #if defined(OS_MACOSX) | 728 #if defined(OS_MACOSX) |
729 #define MAYBE_NewWindowDismissesInstant DISABLED_NewWindowDismissesInstant | 729 #define MAYBE_NewWindowDismissesInstant DISABLED_NewWindowDismissesInstant |
730 #else | 730 #else |
731 #define MAYBE_NewWindowDismissesInstant NewWindowDismissesInstant | 731 #define MAYBE_NewWindowDismissesInstant NewWindowDismissesInstant |
732 #endif | 732 #endif |
733 // Test that creating a new window hides any currently showing Instant overlay. | 733 // Test that creating a new window hides any currently showing Instant overlay. |
734 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NewWindowDismissesInstant) { | 734 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NewWindowDismissesInstant) { |
735 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 735 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
736 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 736 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
737 FocusOmniboxAndWaitForInstantSupport(); | 737 FocusOmniboxAndWaitForInstantSupport(); |
738 SetOmniboxTextAndWaitForOverlayToShow("search"); | 738 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
739 | 739 |
740 Browser* previous_window = browser(); | 740 Browser* previous_window = browser(); |
741 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); | 741 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); |
742 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 742 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
743 | 743 |
744 InstantTestModelObserver observer(instant()->model(), | 744 InstantTestModelObserver observer(instant()->model(), |
745 SearchMode::MODE_DEFAULT); | 745 SearchMode::MODE_DEFAULT); |
746 chrome::NewEmptyWindow(browser()->profile(), | 746 chrome::NewEmptyWindow(browser()->profile(), |
747 chrome::HOST_DESKTOP_TYPE_NATIVE); | 747 chrome::HOST_DESKTOP_TYPE_NATIVE); |
748 observer.WaitForDesiredOverlayState(); | 748 ASSERT_TRUE(observer.WaitForExpectedOverlayState()); |
749 | 749 |
750 // Even though we just created a new Browser object (for the new window), the | 750 // Even though we just created a new Browser object (for the new window), the |
751 // browser() accessor should still give us the first window's Browser object. | 751 // browser() accessor should still give us the first window's Browser object. |
752 EXPECT_EQ(previous_window, browser()); | 752 EXPECT_EQ(previous_window, browser()); |
753 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 753 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
754 EXPECT_TRUE(instant()->model()->mode().is_default()); | 754 EXPECT_TRUE(instant()->model()->mode().is_default()); |
755 } | 755 } |
756 | 756 |
757 // Test that the Instant overlay is recreated when all these conditions are met: | 757 // Test that the Instant overlay is recreated when all these conditions are met: |
758 // - The stale overlay timer has fired. | 758 // - The stale overlay timer has fired. |
759 // - The overlay is not showing. | 759 // - The overlay is not showing. |
760 // - The omnibox doesn't have focus. | 760 // - The omnibox doesn't have focus. |
761 IN_PROC_BROWSER_TEST_F(InstantTest, InstantOverlayRefresh) { | 761 IN_PROC_BROWSER_TEST_F(InstantTest, InstantOverlayRefresh) { |
762 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 762 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
763 FocusOmniboxAndWaitForInstantSupport(); | 763 FocusOmniboxAndWaitForInstantSupport(); |
764 | 764 |
765 // The overlay is refreshed only after all three conditions above are met. | 765 // The overlay is refreshed only after all three conditions above are met. |
766 SetOmniboxTextAndWaitForOverlayToShow("query"); | 766 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
767 instant()->overlay_->is_stale_ = true; | 767 instant()->overlay_->is_stale_ = true; |
768 instant()->ReloadOverlayIfStale(); | 768 instant()->ReloadOverlayIfStale(); |
769 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 769 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
770 instant()->HideOverlay(); | 770 instant()->HideOverlay(); |
771 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 771 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
772 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, | 772 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, |
773 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 773 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
774 EXPECT_FALSE(instant()->overlay_->supports_instant()); | 774 EXPECT_FALSE(instant()->overlay_->supports_instant()); |
775 | 775 |
776 // Try with a different ordering. | 776 // Try with a different ordering. |
777 SetOmniboxTextAndWaitForOverlayToShow("query"); | 777 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
778 instant()->overlay_->is_stale_ = true; | 778 instant()->overlay_->is_stale_ = true; |
779 instant()->ReloadOverlayIfStale(); | 779 instant()->ReloadOverlayIfStale(); |
780 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 780 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
781 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, | 781 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, |
782 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 782 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
783 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideOverlay(). When it | 783 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideOverlay(). When it |
784 // stops hiding the overlay eventually, uncomment these two lines: | 784 // stops hiding the overlay eventually, uncomment these two lines: |
785 // EXPECT_TRUE(instant()->overlay_->supports_instant()); | 785 // EXPECT_TRUE(instant()->overlay_->supports_instant()); |
786 // instant()->HideOverlay(); | 786 // instant()->HideOverlay(); |
787 EXPECT_FALSE(instant()->overlay_->supports_instant()); | 787 EXPECT_FALSE(instant()->overlay_->supports_instant()); |
788 } | 788 } |
789 | 789 |
790 // Test that suggestions are case insensitive. http://crbug.com/150728 | 790 // Test that suggestions are case insensitive. http://crbug.com/150728 |
791 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { | 791 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { |
792 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 792 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
793 FocusOmniboxAndWaitForInstantSupport(); | 793 FocusOmniboxAndWaitForInstantSupport(); |
794 | 794 |
795 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]")); | 795 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]")); |
796 | 796 |
797 SetOmniboxTextAndWaitForOverlayToShow("in"); | 797 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("in")); |
798 EXPECT_EQ(ASCIIToUTF16("instant"), omnibox()->GetText()); | 798 EXPECT_EQ(ASCIIToUTF16("instant"), omnibox()->GetText()); |
799 | 799 |
800 omnibox()->RevertAll(); | 800 omnibox()->RevertAll(); |
801 SetOmniboxTextAndWaitForOverlayToShow("IN"); | 801 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("IN")); |
802 EXPECT_EQ(ASCIIToUTF16("INSTANT"), omnibox()->GetText()); | 802 EXPECT_EQ(ASCIIToUTF16("INSTANT"), omnibox()->GetText()); |
803 | 803 |
804 // U+0130 == LATIN CAPITAL LETTER I WITH DOT ABOVE | 804 // U+0130 == LATIN CAPITAL LETTER I WITH DOT ABOVE |
805 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: '\\u0130NSTANT' } ]")); | 805 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: '\\u0130NSTANT' } ]")); |
806 | 806 |
807 omnibox()->RevertAll(); | 807 omnibox()->RevertAll(); |
808 SetOmniboxTextAndWaitForOverlayToShow("i"); | 808 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("i")); |
809 EXPECT_EQ(WideToUTF16(L"i\u0307nstant"), omnibox()->GetText()); | 809 EXPECT_EQ(WideToUTF16(L"i\u0307nstant"), omnibox()->GetText()); |
810 | 810 |
811 omnibox()->RevertAll(); | 811 omnibox()->RevertAll(); |
812 SetOmniboxTextAndWaitForOverlayToShow("I"); | 812 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("I")); |
813 EXPECT_EQ(WideToUTF16(L"I\u0307nstant"), omnibox()->GetText()); | 813 EXPECT_EQ(WideToUTF16(L"I\u0307nstant"), omnibox()->GetText()); |
814 | 814 |
815 omnibox()->RevertAll(); | 815 omnibox()->RevertAll(); |
816 SetOmniboxTextAndWaitForOverlayToShow(WideToUTF8(L"i\u0307")); | 816 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow(WideToUTF8(L"i\u0307"))); |
817 EXPECT_EQ(WideToUTF16(L"i\u0307nstant"), omnibox()->GetText()); | 817 EXPECT_EQ(WideToUTF16(L"i\u0307nstant"), omnibox()->GetText()); |
818 | 818 |
819 omnibox()->RevertAll(); | 819 omnibox()->RevertAll(); |
820 SetOmniboxTextAndWaitForOverlayToShow(WideToUTF8(L"I\u0307")); | 820 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow(WideToUTF8(L"I\u0307"))); |
821 EXPECT_EQ(WideToUTF16(L"I\u0307nstant"), omnibox()->GetText()); | 821 EXPECT_EQ(WideToUTF16(L"I\u0307nstant"), omnibox()->GetText()); |
822 | 822 |
823 omnibox()->RevertAll(); | 823 omnibox()->RevertAll(); |
824 SetOmniboxTextAndWaitForOverlayToShow(WideToUTF8(L"\u0130")); | 824 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow(WideToUTF8(L"\u0130"))); |
825 EXPECT_EQ(WideToUTF16(L"\u0130NSTANT"), omnibox()->GetText()); | 825 EXPECT_EQ(WideToUTF16(L"\u0130NSTANT"), omnibox()->GetText()); |
826 | 826 |
827 omnibox()->RevertAll(); | 827 omnibox()->RevertAll(); |
828 SetOmniboxTextAndWaitForOverlayToShow("in"); | 828 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("in")); |
829 EXPECT_EQ(ASCIIToUTF16("in"), omnibox()->GetText()); | 829 EXPECT_EQ(ASCIIToUTF16("in"), omnibox()->GetText()); |
830 | 830 |
831 omnibox()->RevertAll(); | 831 omnibox()->RevertAll(); |
832 SetOmniboxTextAndWaitForOverlayToShow("IN"); | 832 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("IN")); |
833 EXPECT_EQ(ASCIIToUTF16("IN"), omnibox()->GetText()); | 833 EXPECT_EQ(ASCIIToUTF16("IN"), omnibox()->GetText()); |
834 | 834 |
835 // Check that a d with a dot above and below it is completed regardless of | 835 // Check that a d with a dot above and below it is completed regardless of |
836 // how that is encoded. | 836 // how that is encoded. |
837 // U+1E0D = LATIN SMALL LETTER D WITH DOT BELOW | 837 // U+1E0D = LATIN SMALL LETTER D WITH DOT BELOW |
838 // U+1E0B = LATIN SMALL LETTER D WITH DOT ABOVE | 838 // U+1E0B = LATIN SMALL LETTER D WITH DOT ABOVE |
839 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: '\\u1e0d\\u0307oh' } ]")); | 839 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: '\\u1e0d\\u0307oh' } ]")); |
840 | 840 |
841 omnibox()->RevertAll(); | 841 omnibox()->RevertAll(); |
842 SetOmniboxTextAndWaitForOverlayToShow(WideToUTF8(L"\u1e0b\u0323")); | 842 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow( |
| 843 WideToUTF8(L"\u1e0b\u0323"))); |
843 EXPECT_EQ(WideToUTF16(L"\u1e0b\u0323oh"), omnibox()->GetText()); | 844 EXPECT_EQ(WideToUTF16(L"\u1e0b\u0323oh"), omnibox()->GetText()); |
844 } | 845 } |
845 | 846 |
846 // Flakes on Windows and Mac: http://crbug.com/170677 | 847 // Flakes on Windows and Mac: http://crbug.com/170677 |
847 #if defined(OS_WIN) || defined(OS_MACOSX) | 848 #if defined(OS_WIN) || defined(OS_MACOSX) |
848 #define MAYBE_CommitInNewTab DISABLED_CommitInNewTab | 849 #define MAYBE_CommitInNewTab DISABLED_CommitInNewTab |
849 #else | 850 #else |
850 #define MAYBE_CommitInNewTab CommitInNewTab | 851 #define MAYBE_CommitInNewTab CommitInNewTab |
851 #endif | 852 #endif |
852 // Test that the overlay can be committed onto a new tab. | 853 // Test that the overlay can be committed onto a new tab. |
853 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_CommitInNewTab) { | 854 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_CommitInNewTab) { |
854 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 855 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
855 FocusOmniboxAndWaitForInstantSupport(); | 856 FocusOmniboxAndWaitForInstantSupport(); |
856 | 857 |
857 // Use the Instant page as the active tab, so we can exploit its visibility | 858 // Use the Instant page as the active tab, so we can exploit its visibility |
858 // handler to check visibility transitions. | 859 // handler to check visibility transitions. |
859 ui_test_utils::NavigateToURL(browser(), instant_url()); | 860 ui_test_utils::NavigateToURL(browser(), instant_url()); |
860 content::WebContents* active_tab = | 861 content::WebContents* active_tab = |
861 browser()->tab_strip_model()->GetActiveWebContents(); | 862 browser()->tab_strip_model()->GetActiveWebContents(); |
862 | 863 |
863 int active_tab_onvisibilitycalls = -1; | 864 int active_tab_onvisibilitycalls = -1; |
864 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", | 865 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", |
865 &active_tab_onvisibilitycalls)); | 866 &active_tab_onvisibilitycalls)); |
866 EXPECT_EQ(0, active_tab_onvisibilitycalls); | 867 EXPECT_EQ(0, active_tab_onvisibilitycalls); |
867 | 868 |
868 SetOmniboxTextAndWaitForOverlayToShow("search"); | 869 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
869 | 870 |
870 // Stash a reference to the overlay, so we can refer to it after commit. | 871 // Stash a reference to the overlay, so we can refer to it after commit. |
871 content::WebContents* overlay = instant()->GetOverlayContents(); | 872 content::WebContents* overlay = instant()->GetOverlayContents(); |
872 EXPECT_TRUE(overlay); | 873 EXPECT_TRUE(overlay); |
873 | 874 |
874 // The state of the searchbox before the commit. | 875 // The state of the searchbox before the commit. |
875 EXPECT_TRUE(UpdateSearchState(overlay)); | 876 EXPECT_TRUE(UpdateSearchState(overlay)); |
876 EXPECT_EQ("search", value_); | 877 EXPECT_EQ("search", value_); |
877 EXPECT_FALSE(verbatim_); | 878 EXPECT_FALSE(verbatim_); |
878 EXPECT_EQ(0, onsubmitcalls_); | 879 EXPECT_EQ(0, onsubmitcalls_); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 } | 930 } |
930 | 931 |
931 // Test that suggestions are reusable. | 932 // Test that suggestions are reusable. |
932 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreReusable) { | 933 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreReusable) { |
933 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 934 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
934 FocusOmniboxAndWaitForInstantSupport(); | 935 FocusOmniboxAndWaitForInstantSupport(); |
935 | 936 |
936 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'instant' } ];" | 937 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'instant' } ];" |
937 "behavior = 'never';")); | 938 "behavior = 'never';")); |
938 | 939 |
939 SetOmniboxTextAndWaitForOverlayToShow("in"); | 940 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("in")); |
940 EXPECT_EQ(ASCIIToUTF16("stant"), GetGrayText()); | 941 EXPECT_EQ(ASCIIToUTF16("stant"), GetGrayText()); |
941 | 942 |
942 SetOmniboxText("ins"); | 943 SetOmniboxText("ins"); |
943 EXPECT_EQ(ASCIIToUTF16("tant"), GetGrayText()); | 944 EXPECT_EQ(ASCIIToUTF16("tant"), GetGrayText()); |
944 | 945 |
945 SetOmniboxText("in"); | 946 SetOmniboxText("in"); |
946 EXPECT_EQ(ASCIIToUTF16("stant"), GetGrayText()); | 947 EXPECT_EQ(ASCIIToUTF16("stant"), GetGrayText()); |
947 | 948 |
948 SetOmniboxText("insane"); | 949 SetOmniboxText("insane"); |
949 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 950 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
950 } | 951 } |
951 | 952 |
952 // Test that the Instant overlay is recreated if it gets destroyed. | 953 // Test that the Instant overlay is recreated if it gets destroyed. |
953 IN_PROC_BROWSER_TEST_F(InstantTest, InstantRenderViewGone) { | 954 IN_PROC_BROWSER_TEST_F(InstantTest, InstantRenderViewGone) { |
954 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 955 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
955 FocusOmniboxAndWaitForInstantSupport(); | 956 FocusOmniboxAndWaitForInstantSupport(); |
956 | 957 |
957 // Type partial query, get suggestion to show. | 958 // Type partial query, get suggestion to show. |
958 SetOmniboxTextAndWaitForOverlayToShow("q"); | 959 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("q")); |
959 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 960 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
960 | 961 |
961 // Kill the Instant renderer and wait for Instant support again. | 962 // Kill the Instant renderer and wait for Instant support again. |
962 KillInstantRenderView(); | 963 KillInstantRenderView(); |
963 FocusOmniboxAndWaitForInstantSupport(); | 964 FocusOmniboxAndWaitForInstantSupport(); |
964 | 965 |
965 SetOmniboxTextAndWaitForOverlayToShow("qu"); | 966 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("qu")); |
966 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 967 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
967 } | 968 } |
968 | 969 |
969 IN_PROC_BROWSER_TEST_F(InstantTest, ProcessIsolation) { | 970 IN_PROC_BROWSER_TEST_F(InstantTest, ProcessIsolation) { |
970 // Prior to setup no render process is dedicated to Instant. | 971 // Prior to setup no render process is dedicated to Instant. |
971 InstantService* instant_service = | 972 InstantService* instant_service = |
972 InstantServiceFactory::GetForProfile(browser()->profile()); | 973 InstantServiceFactory::GetForProfile(browser()->profile()); |
973 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 974 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
974 EXPECT_EQ(0, instant_service->GetInstantProcessCount()); | 975 EXPECT_EQ(0, instant_service->GetInstantProcessCount()); |
975 | 976 |
976 // Setup Instant. | 977 // Setup Instant. |
977 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 978 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
978 FocusOmniboxAndWaitForInstantSupport(); | 979 FocusOmniboxAndWaitForInstantSupport(); |
979 | 980 |
980 // Now there should be a registered Instant render process. | 981 // Now there should be a registered Instant render process. |
981 EXPECT_LT(0, instant_service->GetInstantProcessCount()); | 982 EXPECT_LT(0, instant_service->GetInstantProcessCount()); |
982 | 983 |
983 // And the Instant overlay should live inside it. | 984 // And the Instant overlay should live inside it. |
984 content::WebContents* overlay = instant()->GetOverlayContents(); | 985 content::WebContents* overlay = instant()->GetOverlayContents(); |
985 EXPECT_TRUE(instant_service->IsInstantProcess( | 986 EXPECT_TRUE(instant_service->IsInstantProcess( |
986 overlay->GetRenderProcessHost()->GetID())); | 987 overlay->GetRenderProcessHost()->GetID())); |
987 | 988 |
988 // Search and commit the search by pressing Alt-Enter. | 989 // Search and commit the search by pressing Alt-Enter. |
989 SetOmniboxTextAndWaitForOverlayToShow("tractor"); | 990 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("tractor")); |
990 omnibox()->model()->AcceptInput(NEW_FOREGROUND_TAB, false); | 991 omnibox()->model()->AcceptInput(NEW_FOREGROUND_TAB, false); |
991 | 992 |
992 // The committed search results page should also live inside the | 993 // The committed search results page should also live inside the |
993 // Instant process. | 994 // Instant process. |
994 content::WebContents* active_tab = | 995 content::WebContents* active_tab = |
995 browser()->tab_strip_model()->GetActiveWebContents(); | 996 browser()->tab_strip_model()->GetActiveWebContents(); |
996 EXPECT_TRUE(instant_service->IsInstantProcess( | 997 EXPECT_TRUE(instant_service->IsInstantProcess( |
997 active_tab->GetRenderProcessHost()->GetID())); | 998 active_tab->GetRenderProcessHost()->GetID())); |
998 | 999 |
999 // Navigating away should change the process. | 1000 // Navigating away should change the process. |
1000 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1001 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
1001 EXPECT_FALSE(instant_service->IsInstantProcess( | 1002 EXPECT_FALSE(instant_service->IsInstantProcess( |
1002 active_tab->GetRenderProcessHost()->GetID())); | 1003 active_tab->GetRenderProcessHost()->GetID())); |
1003 } | 1004 } |
OLD | NEW |