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

Side by Side Diff: chrome/browser/ui/search/instant_extended_browsertest.cc

Issue 14130012: InstantExtendedManualTests should fail and not hang (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: virtual dtor Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 224 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
225 225
226 // Focus omnibox and confirm overlay isn't shown. 226 // Focus omnibox and confirm overlay isn't shown.
227 FocusOmniboxAndWaitForInstantExtendedSupport(); 227 FocusOmniboxAndWaitForInstantExtendedSupport();
228 content::WebContents* overlay = instant()->GetOverlayContents(); 228 content::WebContents* overlay = instant()->GetOverlayContents();
229 EXPECT_TRUE(overlay); 229 EXPECT_TRUE(overlay);
230 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); 230 EXPECT_FALSE(instant()->IsOverlayingSearchResults());
231 EXPECT_TRUE(instant()->model()->mode().is_default()); 231 EXPECT_TRUE(instant()->model()->mode().is_default());
232 232
233 // Typing in the omnibox should show the overlay. 233 // Typing in the omnibox should show the overlay.
234 SetOmniboxTextAndWaitForOverlayToShow("query"); 234 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
235 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); 235 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
236 EXPECT_EQ(overlay, instant()->GetOverlayContents()); 236 EXPECT_EQ(overlay, instant()->GetOverlayContents());
237 } 237 }
238 238
239 // Test that middle clicking on a suggestion opens the result in a new tab. 239 // Test that middle clicking on a suggestion opens the result in a new tab.
240 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 240 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
241 MiddleClickOnSuggestionOpensInNewTab) { 241 MiddleClickOnSuggestionOpensInNewTab) {
242 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 242 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
243 FocusOmniboxAndWaitForInstantExtendedSupport(); 243 FocusOmniboxAndWaitForInstantExtendedSupport();
244 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 244 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
245 245
246 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 246 EXPECT_EQ(1, browser()->tab_strip_model()->count());
247 247
248 // Typing in the omnibox should show the overlay. 248 // Typing in the omnibox should show the overlay.
249 SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/"); 249 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/"));
250 250
251 // Create an event listener that opens the top suggestion in a new tab. 251 // Create an event listener that opens the top suggestion in a new tab.
252 EXPECT_TRUE(ExecuteScript( 252 EXPECT_TRUE(ExecuteScript(
253 "var rid = getApiHandle().nativeSuggestions[0].rid;" 253 "var rid = getApiHandle().nativeSuggestions[0].rid;"
254 "document.body.addEventListener('click', function() {" 254 "document.body.addEventListener('click', function() {"
255 "chrome.embeddedSearch.navigateContentWindow(rid, 2);" 255 "chrome.embeddedSearch.navigateContentWindow(rid, 2);"
256 "});" 256 "});"
257 )); 257 ));
258 258
259 content::WindowedNotificationObserver observer( 259 content::WindowedNotificationObserver observer(
(...skipping 16 matching lines...) Expand all
276 } 276 }
277 277
278 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 278 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
279 UnfocusingOmniboxDoesNotChangeSuggestions) { 279 UnfocusingOmniboxDoesNotChangeSuggestions) {
280 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 280 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
281 FocusOmniboxAndWaitForInstantExtendedSupport(); 281 FocusOmniboxAndWaitForInstantExtendedSupport();
282 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 282 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
283 283
284 // Get a committed tab to work with. 284 // Get a committed tab to work with.
285 content::WebContents* instant_tab = instant()->GetOverlayContents(); 285 content::WebContents* instant_tab = instant()->GetOverlayContents();
286 SetOmniboxTextAndWaitForOverlayToShow("committed"); 286 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("committed"));
287 browser()->window()->GetLocationBar()->AcceptInput(); 287 browser()->window()->GetLocationBar()->AcceptInput();
288 288
289 // Put focus back into the omnibox, type, and wait for some gray text. 289 // Put focus back into the omnibox, type, and wait for some gray text.
290 EXPECT_TRUE(content::ExecuteScript(instant_tab, 290 EXPECT_TRUE(content::ExecuteScript(instant_tab,
291 "suggestion = 'santa claus';")); 291 "suggestion = 'santa claus';"));
292 SetOmniboxTextAndWaitForSuggestion("santa "); 292 SetOmniboxTextAndWaitForSuggestion("santa ");
293 EXPECT_EQ(ASCIIToUTF16("claus"), GetGrayText()); 293 EXPECT_EQ(ASCIIToUTF16("claus"), GetGrayText());
294 EXPECT_TRUE(content::ExecuteScript(instant_tab, 294 EXPECT_TRUE(content::ExecuteScript(instant_tab,
295 "onChangeCalls = onNativeSuggestionsCalls = 0;")); 295 "onChangeCalls = onNativeSuggestionsCalls = 0;"));
296 296
297 // Now unfocus the omnibox. 297 // Now unfocus the omnibox.
298 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); 298 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
299 EXPECT_TRUE(UpdateSearchState(instant_tab)); 299 EXPECT_TRUE(UpdateSearchState(instant_tab));
300 EXPECT_EQ(0, on_change_calls_); 300 EXPECT_EQ(0, on_change_calls_);
301 EXPECT_EQ(0, on_native_suggestions_calls_); 301 EXPECT_EQ(0, on_native_suggestions_calls_);
302 } 302 }
303 303
304 // Test that omnibox text is correctly set when overlay is committed with Enter. 304 // Test that omnibox text is correctly set when overlay is committed with Enter.
305 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) { 305 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) {
306 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 306 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
307 FocusOmniboxAndWaitForInstantExtendedSupport(); 307 FocusOmniboxAndWaitForInstantExtendedSupport();
308 308
309 // The page will autocomplete once we set the omnibox value. 309 // The page will autocomplete once we set the omnibox value.
310 EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';")); 310 EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';"));
311 311
312 // Set the text, and wait for suggestions to show up. 312 // Set the text, and wait for suggestions to show up.
313 SetOmniboxTextAndWaitForOverlayToShow("santa"); 313 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("santa"));
314 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); 314 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText());
315 315
316 // Test that the current suggestion is correctly set. 316 // Test that the current suggestion is correctly set.
317 EXPECT_EQ(ASCIIToUTF16(" claus"), GetGrayText()); 317 EXPECT_EQ(ASCIIToUTF16(" claus"), GetGrayText());
318 318
319 // Commit the search by pressing Enter. 319 // Commit the search by pressing Enter.
320 browser()->window()->GetLocationBar()->AcceptInput(); 320 browser()->window()->GetLocationBar()->AcceptInput();
321 321
322 // 'Enter' commits the query as it was typed. 322 // 'Enter' commits the query as it was typed.
323 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); 323 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText());
324 324
325 // Suggestion should be cleared at this point. 325 // Suggestion should be cleared at this point.
326 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); 326 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText());
327 } 327 }
328 328
329 // Test that omnibox text is correctly set when committed with focus lost. 329 // Test that omnibox text is correctly set when committed with focus lost.
330 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) { 330 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) {
331 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 331 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
332 FocusOmniboxAndWaitForInstantExtendedSupport(); 332 FocusOmniboxAndWaitForInstantExtendedSupport();
333 333
334 // Set autocomplete text (grey text). 334 // Set autocomplete text (grey text).
335 EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';")); 335 EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';"));
336 336
337 // Set the text, and wait for suggestions to show up. 337 // Set the text, and wait for suggestions to show up.
338 SetOmniboxTextAndWaitForOverlayToShow("johnny"); 338 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("johnny"));
339 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); 339 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText());
340 340
341 // Test that the current suggestion is correctly set. 341 // Test that the current suggestion is correctly set.
342 EXPECT_EQ(ASCIIToUTF16(" depp"), GetGrayText()); 342 EXPECT_EQ(ASCIIToUTF16(" depp"), GetGrayText());
343 343
344 // Commit the overlay by lost focus (e.g. clicking on the page). 344 // Commit the overlay by lost focus (e.g. clicking on the page).
345 instant()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); 345 instant()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST);
346 346
347 // Omnibox text and suggestion should not be changed. 347 // Omnibox text and suggestion should not be changed.
348 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); 348 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText());
349 EXPECT_EQ(ASCIIToUTF16(" depp"), GetGrayText()); 349 EXPECT_EQ(ASCIIToUTF16(" depp"), GetGrayText());
350 } 350 }
351 351
352 // Test that omnibox text is correctly set when clicking on committed SERP. 352 // Test that omnibox text is correctly set when clicking on committed SERP.
353 // Disabled on Mac because omnibox focus loss is not working correctly. 353 // Disabled on Mac because omnibox focus loss is not working correctly.
354 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 354 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
355 OmniboxTextUponFocusedCommittedSERP) { 355 OmniboxTextUponFocusedCommittedSERP) {
356 // Setup Instant. 356 // Setup Instant.
357 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 357 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
358 FocusOmniboxAndWaitForInstantExtendedSupport(); 358 FocusOmniboxAndWaitForInstantExtendedSupport();
359 359
360 // Create an observer to wait for the instant tab to support Instant. 360 // Create an observer to wait for the instant tab to support Instant.
361 content::WindowedNotificationObserver observer( 361 content::WindowedNotificationObserver observer(
362 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 362 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
363 content::NotificationService::AllSources()); 363 content::NotificationService::AllSources());
364 364
365 // Do a search and commit it. 365 // Do a search and commit it.
366 SetOmniboxTextAndWaitForOverlayToShow("hello k"); 366 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello k"));
367 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); 367 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText());
368 browser()->window()->GetLocationBar()->AcceptInput(); 368 browser()->window()->GetLocationBar()->AcceptInput();
369 observer.Wait(); 369 observer.Wait();
370 370
371 // With a committed results page, do a search by unfocusing the omnibox and 371 // With a committed results page, do a search by unfocusing the omnibox and
372 // focusing the contents. 372 // focusing the contents.
373 SetOmniboxText("hello"); 373 SetOmniboxText("hello");
374 // Calling handleOnChange manually to make sure it is called before the 374 // Calling handleOnChange manually to make sure it is called before the
375 // Focus() call below. 375 // Focus() call below.
376 EXPECT_TRUE(content::ExecuteScript(instant()->instant_tab()->contents(), 376 EXPECT_TRUE(content::ExecuteScript(instant()->instant_tab()->contents(),
(...skipping 10 matching lines...) Expand all
387 // suggestion comes in. 387 // suggestion comes in.
388 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 388 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
389 NavigationSuggestionIsDiscardedUponSearchSuggestion) { 389 NavigationSuggestionIsDiscardedUponSearchSuggestion) {
390 // Setup Instant. 390 // Setup Instant.
391 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 391 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
392 FocusOmniboxAndWaitForInstantExtendedSupport(); 392 FocusOmniboxAndWaitForInstantExtendedSupport();
393 393
394 // Tell the page to send a URL suggestion. 394 // Tell the page to send a URL suggestion.
395 EXPECT_TRUE(ExecuteScript("suggestion = 'http://www.example.com';" 395 EXPECT_TRUE(ExecuteScript("suggestion = 'http://www.example.com';"
396 "behavior = 1;")); 396 "behavior = 1;"));
397 SetOmniboxTextAndWaitForOverlayToShow("exa"); 397 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("exa"));
398 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); 398 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText());
399 399
400 // Now send a search suggestion and see that Navigation suggestion is no 400 // Now send a search suggestion and see that Navigation suggestion is no
401 // longer kept. 401 // longer kept.
402 EXPECT_TRUE(ExecuteScript("suggestion = 'exams are great';" 402 EXPECT_TRUE(ExecuteScript("suggestion = 'exams are great';"
403 "behavior = 2;")); 403 "behavior = 2;"));
404 SetOmniboxText("exam"); 404 SetOmniboxText("exam");
405 // Wait for JavaScript to run handleOnChange by executing a blank script. 405 // Wait for JavaScript to run handleOnChange by executing a blank script.
406 EXPECT_TRUE(ExecuteScript(std::string())); 406 EXPECT_TRUE(ExecuteScript(std::string()));
407 407
408 instant()->overlay()->contents()->GetView()->Focus(); 408 instant()->overlay()->contents()->GetView()->Focus();
409 EXPECT_EQ(ASCIIToUTF16("exam"), omnibox()->GetText()); 409 EXPECT_EQ(ASCIIToUTF16("exam"), omnibox()->GetText());
410 EXPECT_EQ(ASCIIToUTF16("s are great"), GetGrayText()); 410 EXPECT_EQ(ASCIIToUTF16("s are great"), GetGrayText());
411 411
412 // TODO(jered): Remove this after fixing OnBlur(). 412 // TODO(jered): Remove this after fixing OnBlur().
413 omnibox()->RevertAll(); 413 omnibox()->RevertAll();
414 } 414 }
415 415
416 // This test simulates a search provider using the InstantExtended API to 416 // This test simulates a search provider using the InstantExtended API to
417 // navigate through the suggested results and back to the original user query. 417 // navigate through the suggested results and back to the original user query.
418 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { 418 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) {
419 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 419 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
420 FocusOmniboxAndWaitForInstantExtendedSupport(); 420 FocusOmniboxAndWaitForInstantExtendedSupport();
421 421
422 SetOmniboxTextAndWaitForOverlayToShow("hello"); 422 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello"));
423 EXPECT_EQ("hello", GetOmniboxText()); 423 EXPECT_EQ("hello", GetOmniboxText());
424 424
425 SendDownArrow(); 425 SendDownArrow();
426 EXPECT_EQ("result 1", GetOmniboxText()); 426 EXPECT_EQ("result 1", GetOmniboxText());
427 SendDownArrow(); 427 SendDownArrow();
428 EXPECT_EQ("result 2", GetOmniboxText()); 428 EXPECT_EQ("result 2", GetOmniboxText());
429 SendUpArrow(); 429 SendUpArrow();
430 EXPECT_EQ("result 1", GetOmniboxText()); 430 EXPECT_EQ("result 1", GetOmniboxText());
431 SendUpArrow(); 431 SendUpArrow();
432 EXPECT_EQ("hello", GetOmniboxText()); 432 EXPECT_EQ("hello", GetOmniboxText());
(...skipping 24 matching lines...) Expand all
457 NavigateToURLSuggestionHitEnterAndLookForSubmit) { 457 NavigateToURLSuggestionHitEnterAndLookForSubmit) {
458 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 458 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
459 FocusOmniboxAndWaitForInstantExtendedSupport(); 459 FocusOmniboxAndWaitForInstantExtendedSupport();
460 460
461 // Create an observer to wait for the instant tab to support Instant. 461 // Create an observer to wait for the instant tab to support Instant.
462 content::WindowedNotificationObserver observer( 462 content::WindowedNotificationObserver observer(
463 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 463 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
464 content::NotificationService::AllSources()); 464 content::NotificationService::AllSources());
465 465
466 // Do a search and commit it. 466 // Do a search and commit it.
467 SetOmniboxTextAndWaitForOverlayToShow("hello k"); 467 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello k"));
468 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); 468 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText());
469 browser()->window()->GetLocationBar()->AcceptInput(); 469 browser()->window()->GetLocationBar()->AcceptInput();
470 observer.Wait(); 470 observer.Wait();
471 471
472 SetOmniboxText("http"); 472 SetOmniboxText("http");
473 EXPECT_EQ("http", GetOmniboxText()); 473 EXPECT_EQ("http", GetOmniboxText());
474 474
475 SendDownArrow(); 475 SendDownArrow();
476 EXPECT_EQ("result 1", GetOmniboxText()); 476 EXPECT_EQ("result 1", GetOmniboxText());
477 SendDownArrow(); 477 SendDownArrow();
(...skipping 18 matching lines...) Expand all
496 EXPECT_EQ(old_query_value, query_value_); 496 EXPECT_EQ(old_query_value, query_value_);
497 } 497 }
498 498
499 // This test simulates a search provider using the InstantExtended API to 499 // This test simulates a search provider using the InstantExtended API to
500 // navigate through the suggested results and hitting escape to get back to the 500 // navigate through the suggested results and hitting escape to get back to the
501 // original user query. 501 // original user query.
502 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { 502 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) {
503 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 503 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
504 FocusOmniboxAndWaitForInstantExtendedSupport(); 504 FocusOmniboxAndWaitForInstantExtendedSupport();
505 505
506 SetOmniboxTextAndWaitForOverlayToShow("hello"); 506 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello"));
507 EXPECT_EQ("hello", GetOmniboxText()); 507 EXPECT_EQ("hello", GetOmniboxText());
508 508
509 SendDownArrow(); 509 SendDownArrow();
510 EXPECT_EQ("result 1", GetOmniboxText()); 510 EXPECT_EQ("result 1", GetOmniboxText());
511 SendDownArrow(); 511 SendDownArrow();
512 EXPECT_EQ("result 2", GetOmniboxText()); 512 EXPECT_EQ("result 2", GetOmniboxText());
513 SendEscape(); 513 SendEscape();
514 EXPECT_EQ("hello", GetOmniboxText()); 514 EXPECT_EQ("hello", GetOmniboxText());
515 515
516 // Ensure that the API's value is set correctly. 516 // Ensure that the API's value is set correctly.
(...skipping 12 matching lines...) Expand all
529 } 529 }
530 530
531 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PressEscapeWithBlueText) { 531 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PressEscapeWithBlueText) {
532 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 532 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
533 FocusOmniboxAndWaitForInstantExtendedSupport(); 533 FocusOmniboxAndWaitForInstantExtendedSupport();
534 534
535 // Set blue text completion. 535 // Set blue text completion.
536 EXPECT_TRUE(ExecuteScript("suggestion = 'chimichanga.com';" 536 EXPECT_TRUE(ExecuteScript("suggestion = 'chimichanga.com';"
537 "behavior = 1;")); 537 "behavior = 1;"));
538 538
539 SetOmniboxTextAndWaitForOverlayToShow("chimi"); 539 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("chimi"));
540 540
541 EXPECT_EQ(ASCIIToUTF16("chimichanga.com"), omnibox()->GetText()); 541 EXPECT_EQ(ASCIIToUTF16("chimichanga.com"), omnibox()->GetText());
542 EXPECT_EQ(ASCIIToUTF16("changa.com"), GetBlueText()); 542 EXPECT_EQ(ASCIIToUTF16("changa.com"), GetBlueText());
543 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); 543 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText());
544 544
545 EXPECT_TRUE(ExecuteScript("onChangeCalls = onNativeSuggestionsCalls = 0;")); 545 EXPECT_TRUE(ExecuteScript("onChangeCalls = onNativeSuggestionsCalls = 0;"));
546 546
547 SendDownArrow(); 547 SendDownArrow();
548 548
549 EXPECT_EQ(ASCIIToUTF16("result 1"), omnibox()->GetText()); 549 EXPECT_EQ(ASCIIToUTF16("result 1"), omnibox()->GetText());
(...skipping 16 matching lines...) Expand all
566 } 566 }
567 567
568 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PressEscapeWithGrayText) { 568 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PressEscapeWithGrayText) {
569 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 569 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
570 FocusOmniboxAndWaitForInstantExtendedSupport(); 570 FocusOmniboxAndWaitForInstantExtendedSupport();
571 571
572 // Set gray text completion. 572 // Set gray text completion.
573 EXPECT_TRUE(ExecuteScript("suggestion = 'cowabunga';" 573 EXPECT_TRUE(ExecuteScript("suggestion = 'cowabunga';"
574 "behavior = 2;")); 574 "behavior = 2;"));
575 575
576 SetOmniboxTextAndWaitForOverlayToShow("cowa"); 576 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("cowa"));
577 577
578 EXPECT_EQ(ASCIIToUTF16("cowa"), omnibox()->GetText()); 578 EXPECT_EQ(ASCIIToUTF16("cowa"), omnibox()->GetText());
579 EXPECT_EQ(ASCIIToUTF16(""), GetBlueText()); 579 EXPECT_EQ(ASCIIToUTF16(""), GetBlueText());
580 EXPECT_EQ(ASCIIToUTF16("bunga"), GetGrayText()); 580 EXPECT_EQ(ASCIIToUTF16("bunga"), GetGrayText());
581 581
582 EXPECT_TRUE(ExecuteScript("onChangeCalls = onNativeSuggestionsCalls = 0;")); 582 EXPECT_TRUE(ExecuteScript("onChangeCalls = onNativeSuggestionsCalls = 0;"));
583 583
584 SendDownArrow(); 584 SendDownArrow();
585 585
586 EXPECT_EQ(ASCIIToUTF16("result 1"), omnibox()->GetText()); 586 EXPECT_EQ(ASCIIToUTF16("result 1"), omnibox()->GetText());
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 // site instances. 824 // site instances.
825 // TODO(sreeram): |ntp_| is going away, so this check can be removed in the 825 // TODO(sreeram): |ntp_| is going away, so this check can be removed in the
826 // future. 826 // future.
827 content::WebContents* overlay = instant()->GetOverlayContents(); 827 content::WebContents* overlay = instant()->GetOverlayContents();
828 content::WebContents* ntp_contents = instant()->ntp_->contents(); 828 content::WebContents* ntp_contents = instant()->ntp_->contents();
829 EXPECT_FALSE(overlay->GetSiteInstance()->IsRelatedSiteInstance( 829 EXPECT_FALSE(overlay->GetSiteInstance()->IsRelatedSiteInstance(
830 ntp_contents->GetSiteInstance())); 830 ntp_contents->GetSiteInstance()));
831 831
832 // Type a query and hit enter to get a results page. The overlay becomes the 832 // Type a query and hit enter to get a results page. The overlay becomes the
833 // active tab. 833 // active tab.
834 SetOmniboxTextAndWaitForOverlayToShow("hello"); 834 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello"));
835 EXPECT_EQ("hello", GetOmniboxText()); 835 EXPECT_EQ("hello", GetOmniboxText());
836 browser()->window()->GetLocationBar()->AcceptInput(); 836 browser()->window()->GetLocationBar()->AcceptInput();
837 content::WebContents* first_active_tab = 837 content::WebContents* first_active_tab =
838 browser()->tab_strip_model()->GetActiveWebContents(); 838 browser()->tab_strip_model()->GetActiveWebContents();
839 EXPECT_EQ(first_active_tab, overlay); 839 EXPECT_EQ(first_active_tab, overlay);
840 scoped_refptr<content::SiteInstance> first_site_instance = 840 scoped_refptr<content::SiteInstance> first_site_instance =
841 first_active_tab->GetSiteInstance(); 841 first_active_tab->GetSiteInstance();
842 EXPECT_FALSE(first_site_instance->IsRelatedSiteInstance( 842 EXPECT_FALSE(first_site_instance->IsRelatedSiteInstance(
843 ntp_contents->GetSiteInstance())); 843 ntp_contents->GetSiteInstance()));
844 844
845 // Navigating elsewhere gets us off of the commited page. The next 845 // Navigating elsewhere gets us off of the commited page. The next
846 // query will give us a new |overlay| which we will then commit. 846 // query will give us a new |overlay| which we will then commit.
847 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 847 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
848 848
849 // Show and commit the new overlay. 849 // Show and commit the new overlay.
850 SetOmniboxTextAndWaitForOverlayToShow("hello again"); 850 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello again"));
851 EXPECT_EQ("hello again", GetOmniboxText()); 851 EXPECT_EQ("hello again", GetOmniboxText());
852 browser()->window()->GetLocationBar()->AcceptInput(); 852 browser()->window()->GetLocationBar()->AcceptInput();
853 content::WebContents* second_active_tab = 853 content::WebContents* second_active_tab =
854 browser()->tab_strip_model()->GetActiveWebContents(); 854 browser()->tab_strip_model()->GetActiveWebContents();
855 EXPECT_NE(first_active_tab, second_active_tab); 855 EXPECT_NE(first_active_tab, second_active_tab);
856 scoped_refptr<content::SiteInstance> second_site_instance = 856 scoped_refptr<content::SiteInstance> second_site_instance =
857 second_active_tab->GetSiteInstance(); 857 second_active_tab->GetSiteInstance();
858 EXPECT_NE(first_site_instance, second_site_instance); 858 EXPECT_NE(first_site_instance, second_site_instance);
859 EXPECT_FALSE(first_site_instance->IsRelatedSiteInstance( 859 EXPECT_FALSE(first_site_instance->IsRelatedSiteInstance(
860 second_site_instance)); 860 second_site_instance));
861 } 861 }
862 862
863 // Tests that suggestions are sanity checked. 863 // Tests that suggestions are sanity checked.
864 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) { 864 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) {
865 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 865 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
866 FocusOmniboxAndWaitForInstantExtendedSupport(); 866 FocusOmniboxAndWaitForInstantExtendedSupport();
867 867
868 // Do not set gray text that is not a suffix of the query. 868 // Do not set gray text that is not a suffix of the query.
869 EXPECT_TRUE(ExecuteScript("suggestion = 'potato';" 869 EXPECT_TRUE(ExecuteScript("suggestion = 'potato';"
870 "behavior = 2;")); 870 "behavior = 2;"));
871 SetOmniboxTextAndWaitForOverlayToShow("query"); 871 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
872 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); 872 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText());
873 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); 873 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText());
874 874
875 omnibox()->RevertAll(); 875 omnibox()->RevertAll();
876 876
877 // Do not set blue text that is not a valid URL completion. 877 // Do not set blue text that is not a valid URL completion.
878 EXPECT_TRUE(ExecuteScript("suggestion = 'this is not a url!';" 878 EXPECT_TRUE(ExecuteScript("suggestion = 'this is not a url!';"
879 "behavior = 1;")); 879 "behavior = 1;"));
880 SetOmniboxTextAndWaitForOverlayToShow("this is"); 880 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("this is"));
881 EXPECT_EQ(ASCIIToUTF16("this is"), omnibox()->GetText()); 881 EXPECT_EQ(ASCIIToUTF16("this is"), omnibox()->GetText());
882 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); 882 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText());
883 883
884 omnibox()->RevertAll(); 884 omnibox()->RevertAll();
885 885
886 // Do not set gray text when blue text is already set. 886 // Do not set gray text when blue text is already set.
887 // First set up some blue text completion. 887 // First set up some blue text completion.
888 EXPECT_TRUE(ExecuteScript("suggestion = 'www.example.com';" 888 EXPECT_TRUE(ExecuteScript("suggestion = 'www.example.com';"
889 "behavior = 1;")); 889 "behavior = 1;"));
890 SetOmniboxTextAndWaitForOverlayToShow("http://www.ex"); 890 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://www.ex"));
891 EXPECT_EQ(ASCIIToUTF16("http://www.example.com"), omnibox()->GetText()); 891 EXPECT_EQ(ASCIIToUTF16("http://www.example.com"), omnibox()->GetText());
892 EXPECT_EQ(ASCIIToUTF16("ample.com"), GetBlueText()); 892 EXPECT_EQ(ASCIIToUTF16("ample.com"), GetBlueText());
893 893
894 // Now try to set gray text for the same query. 894 // Now try to set gray text for the same query.
895 EXPECT_TRUE(ExecuteScript("suggestion = 'www.example.com rocks';" 895 EXPECT_TRUE(ExecuteScript("suggestion = 'www.example.com rocks';"
896 "behavior = 2;")); 896 "behavior = 2;"));
897 SetOmniboxText("http://www.ex"); 897 SetOmniboxText("http://www.ex");
898 EXPECT_EQ(ASCIIToUTF16("http://www.example.com"), omnibox()->GetText()); 898 EXPECT_EQ(ASCIIToUTF16("http://www.example.com"), omnibox()->GetText());
899 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); 899 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText());
900 900
901 omnibox()->RevertAll(); 901 omnibox()->RevertAll();
902 902
903 // Ignore an out-of-date blue text suggestion. (Simulates a laggy 903 // Ignore an out-of-date blue text suggestion. (Simulates a laggy
904 // SetSuggestion IPC by directly calling into InstantController.) 904 // SetSuggestion IPC by directly calling into InstantController.)
905 SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/"); 905 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/"));
906 instant()->SetSuggestions( 906 instant()->SetSuggestions(
907 instant()->overlay()->contents(), 907 instant()->overlay()->contents(),
908 std::vector<InstantSuggestion>( 908 std::vector<InstantSuggestion>(
909 1, 909 1,
910 InstantSuggestion(ASCIIToUTF16("www.exa"), 910 InstantSuggestion(ASCIIToUTF16("www.exa"),
911 INSTANT_COMPLETE_NOW, 911 INSTANT_COMPLETE_NOW,
912 INSTANT_SUGGESTION_URL, 912 INSTANT_SUGGESTION_URL,
913 ASCIIToUTF16("www.exa")))); 913 ASCIIToUTF16("www.exa"))));
914 EXPECT_EQ( 914 EXPECT_EQ(
915 "http://www.example.com/", 915 "http://www.example.com/",
916 omnibox()->model()->result().default_match()->destination_url.spec()); 916 omnibox()->model()->result().default_match()->destination_url.spec());
917 917
918 omnibox()->RevertAll(); 918 omnibox()->RevertAll();
919 919
920 // TODO(samarth): uncomment after fixing crbug.com/191656. 920 // TODO(samarth): uncomment after fixing crbug.com/191656.
921 // Use an out-of-date blue text suggestion, if the text typed by the user is 921 // Use an out-of-date blue text suggestion, if the text typed by the user is
922 // contained in the suggestion. 922 // contained in the suggestion.
923 // SetOmniboxTextAndWaitForOverlayToShow("ex"); 923 // ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("ex"));
924 // instant()->SetSuggestions( 924 // instant()->SetSuggestions(
925 // instant()->overlay()->contents(), 925 // instant()->overlay()->contents(),
926 // std::vector<InstantSuggestion>( 926 // std::vector<InstantSuggestion>(
927 // 1, 927 // 1,
928 // InstantSuggestion(ASCIIToUTF16("www.example.com"), 928 // InstantSuggestion(ASCIIToUTF16("www.example.com"),
929 // INSTANT_COMPLETE_NOW, 929 // INSTANT_COMPLETE_NOW,
930 // INSTANT_SUGGESTION_URL, 930 // INSTANT_SUGGESTION_URL,
931 // ASCIIToUTF16("e")))); 931 // ASCIIToUTF16("e"))));
932 // EXPECT_EQ( 932 // EXPECT_EQ(
933 // "http://www.example.com/", 933 // "http://www.example.com/",
(...skipping 15 matching lines...) Expand all
949 // Tests that a previous navigation suggestion is not discarded if it's not 949 // Tests that a previous navigation suggestion is not discarded if it's not
950 // stale. 950 // stale.
951 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 951 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
952 NavigationSuggestionIsNotDiscarded) { 952 NavigationSuggestionIsNotDiscarded) {
953 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 953 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
954 FocusOmniboxAndWaitForInstantExtendedSupport(); 954 FocusOmniboxAndWaitForInstantExtendedSupport();
955 955
956 // Tell the page to send a URL suggestion. 956 // Tell the page to send a URL suggestion.
957 EXPECT_TRUE(ExecuteScript("suggestion = 'http://www.example.com';" 957 EXPECT_TRUE(ExecuteScript("suggestion = 'http://www.example.com';"
958 "behavior = 1;")); 958 "behavior = 1;"));
959 SetOmniboxTextAndWaitForOverlayToShow("exa"); 959 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("exa"));
960 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); 960 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText());
961 SetOmniboxText("exam"); 961 SetOmniboxText("exam");
962 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); 962 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText());
963 963
964 // TODO(jered): Remove this after fixing OnBlur(). 964 // TODO(jered): Remove this after fixing OnBlur().
965 omnibox()->RevertAll(); 965 omnibox()->RevertAll();
966 } 966 }
967 967
968 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. 968 // TODO(dhollowa): Fix flakes. http://crbug.com/179930.
969 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_MostVisited) { 969 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_MostVisited) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 // Instant-provided NTP should not have any bindings enabled. 1134 // Instant-provided NTP should not have any bindings enabled.
1135 EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings()); 1135 EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings());
1136 } 1136 }
1137 1137
1138 // WebUIBindings should never be enabled on ANY Instant web contents. 1138 // WebUIBindings should never be enabled on ANY Instant web contents.
1139 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnPreview) { 1139 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnPreview) {
1140 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1140 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1141 FocusOmniboxAndWaitForInstantExtendedSupport(); 1141 FocusOmniboxAndWaitForInstantExtendedSupport();
1142 1142
1143 // Typing in the omnibox shows the overlay. 1143 // Typing in the omnibox shows the overlay.
1144 SetOmniboxTextAndWaitForOverlayToShow("query"); 1144 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
1145 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); 1145 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
1146 content::WebContents* preview = instant()->GetOverlayContents(); 1146 content::WebContents* preview = instant()->GetOverlayContents();
1147 ASSERT_NE(static_cast<content::WebContents*>(NULL), preview); 1147 ASSERT_NE(static_cast<content::WebContents*>(NULL), preview);
1148 1148
1149 // Instant preview should not have any bindings enabled. 1149 // Instant preview should not have any bindings enabled.
1150 EXPECT_EQ(0, preview->GetRenderViewHost()->GetEnabledBindings()); 1150 EXPECT_EQ(0, preview->GetRenderViewHost()->GetEnabledBindings());
1151 } 1151 }
1152 1152
1153 // WebUIBindings should never be enabled on ANY Instant web contents. 1153 // WebUIBindings should never be enabled on ANY Instant web contents.
1154 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnResults) { 1154 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnResults) {
1155 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1155 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1156 FocusOmniboxAndWaitForInstantExtendedSupport(); 1156 FocusOmniboxAndWaitForInstantExtendedSupport();
1157 1157
1158 // Typing in the omnibox shows the overlay. 1158 // Typing in the omnibox shows the overlay.
1159 SetOmniboxTextAndWaitForOverlayToShow("query"); 1159 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
1160 content::WebContents* preview = instant()->GetOverlayContents(); 1160 content::WebContents* preview = instant()->GetOverlayContents();
1161 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); 1161 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
1162 // Commit the search by pressing Enter. 1162 // Commit the search by pressing Enter.
1163 browser()->window()->GetLocationBar()->AcceptInput(); 1163 browser()->window()->GetLocationBar()->AcceptInput();
1164 EXPECT_TRUE(instant()->model()->mode().is_default()); 1164 EXPECT_TRUE(instant()->model()->mode().is_default());
1165 const content::WebContents* tab = 1165 const content::WebContents* tab =
1166 browser()->tab_strip_model()->GetActiveWebContents(); 1166 browser()->tab_strip_model()->GetActiveWebContents();
1167 EXPECT_EQ(preview, tab); 1167 EXPECT_EQ(preview, tab);
1168 1168
1169 // The commited Instant page should not have any bindings enabled. 1169 // The commited Instant page should not have any bindings enabled.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1219 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1220 1220
1221 // Focus omnibox and confirm overlay isn't shown. 1221 // Focus omnibox and confirm overlay isn't shown.
1222 FocusOmniboxAndWaitForInstantExtendedSupport(); 1222 FocusOmniboxAndWaitForInstantExtendedSupport();
1223 content::WebContents* overlay = instant()->GetOverlayContents(); 1223 content::WebContents* overlay = instant()->GetOverlayContents();
1224 EXPECT_TRUE(overlay); 1224 EXPECT_TRUE(overlay);
1225 EXPECT_TRUE(instant()->model()->mode().is_default()); 1225 EXPECT_TRUE(instant()->model()->mode().is_default());
1226 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); 1226 EXPECT_FALSE(instant()->IsOverlayingSearchResults());
1227 1227
1228 // Typing in the omnibox should show the overlay. 1228 // Typing in the omnibox should show the overlay.
1229 SetOmniboxTextAndWaitForOverlayToShow("query"); 1229 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
1230 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); 1230 EXPECT_TRUE(instant()->IsOverlayingSearchResults());
1231 EXPECT_EQ(overlay, instant()->GetOverlayContents()); 1231 EXPECT_EQ(overlay, instant()->GetOverlayContents());
1232 1232
1233 // Explicitly unfocus the omnibox without triggering a click. Note that this 1233 // Explicitly unfocus the omnibox without triggering a click. Note that this
1234 // doesn't actually change the focus state of the omnibox, only what the 1234 // doesn't actually change the focus state of the omnibox, only what the
1235 // Instant controller sees it as. 1235 // Instant controller sees it as.
1236 omnibox()->model()->OnWillKillFocus(NULL); 1236 omnibox()->model()->OnWillKillFocus(NULL);
1237 omnibox()->model()->OnKillFocus(); 1237 omnibox()->model()->OnKillFocus();
1238 1238
1239 // Confirm that the overlay has been committed. 1239 // Confirm that the overlay has been committed.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 FocusOmniboxAndWaitForInstantSupport(); 1314 FocusOmniboxAndWaitForInstantSupport();
1315 content::WebContents* overlay = instant()->GetOverlayContents(); 1315 content::WebContents* overlay = instant()->GetOverlayContents();
1316 EXPECT_TRUE(overlay); 1316 EXPECT_TRUE(overlay);
1317 EXPECT_TRUE(instant()->model()->mode().is_default()); 1317 EXPECT_TRUE(instant()->model()->mode().is_default());
1318 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); 1318 EXPECT_FALSE(instant()->IsOverlayingSearchResults());
1319 1319
1320 // Commit the overlay without triggering a navigation. 1320 // Commit the overlay without triggering a navigation.
1321 content::WindowedNotificationObserver observer( 1321 content::WindowedNotificationObserver observer(
1322 chrome::NOTIFICATION_INSTANT_COMMITTED, 1322 chrome::NOTIFICATION_INSTANT_COMMITTED,
1323 content::NotificationService::AllSources()); 1323 content::NotificationService::AllSources());
1324 SetOmniboxTextAndWaitForOverlayToShow("query"); 1324 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
1325 browser()->window()->GetLocationBar()->AcceptInput(); 1325 browser()->window()->GetLocationBar()->AcceptInput();
1326 observer.Wait(); 1326 observer.Wait();
1327 1327
1328 // Confirm that the overlay has been committed. 1328 // Confirm that the overlay has been committed.
1329 content::WebContents* active_tab = 1329 content::WebContents* active_tab =
1330 browser()->tab_strip_model()->GetActiveWebContents(); 1330 browser()->tab_strip_model()->GetActiveWebContents();
1331 EXPECT_EQ(overlay, active_tab); 1331 EXPECT_EQ(overlay, active_tab);
1332 1332
1333 // The page hasn't navigated so there should be a transient entry with the 1333 // The page hasn't navigated so there should be a transient entry with the
1334 // same URL but different page ID as the last committed entry. 1334 // same URL but different page ID as the last committed entry.
(...skipping 24 matching lines...) Expand all
1359 content::NotificationService::AllSources()); 1359 content::NotificationService::AllSources());
1360 1360
1361 // Trigger a navigation on commit. 1361 // Trigger a navigation on commit.
1362 EXPECT_TRUE(ExecuteScript( 1362 EXPECT_TRUE(ExecuteScript(
1363 "getApiHandle().oncancel = function() {" 1363 "getApiHandle().oncancel = function() {"
1364 " location.replace(location.href + '#q=query');" 1364 " location.replace(location.href + '#q=query');"
1365 "};" 1365 "};"
1366 )); 1366 ));
1367 1367
1368 // Commit the overlay. 1368 // Commit the overlay.
1369 SetOmniboxTextAndWaitForOverlayToShow("query"); 1369 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
1370 browser()->window()->GetLocationBar()->AcceptInput(); 1370 browser()->window()->GetLocationBar()->AcceptInput();
1371 observer.Wait(); 1371 observer.Wait();
1372 1372
1373 // Confirm that the overlay has been committed. 1373 // Confirm that the overlay has been committed.
1374 content::WebContents* active_tab = 1374 content::WebContents* active_tab =
1375 browser()->tab_strip_model()->GetActiveWebContents(); 1375 browser()->tab_strip_model()->GetActiveWebContents();
1376 EXPECT_EQ(overlay, active_tab); 1376 EXPECT_EQ(overlay, active_tab);
1377 1377
1378 // The page has navigated so there should be no transient entry. 1378 // The page has navigated so there should be no transient entry.
1379 const content::NavigationEntry* transient_entry = 1379 const content::NavigationEntry* transient_entry =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 // Test that autocomplete results are sent to the page only when all the 1461 // Test that autocomplete results are sent to the page only when all the
1462 // providers are done. 1462 // providers are done.
1463 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, AutocompleteProvidersDone) { 1463 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, AutocompleteProvidersDone) {
1464 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1464 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1465 FocusOmniboxAndWaitForInstantExtendedSupport(); 1465 FocusOmniboxAndWaitForInstantExtendedSupport();
1466 1466
1467 content::WebContents* overlay = instant()->GetOverlayContents(); 1467 content::WebContents* overlay = instant()->GetOverlayContents();
1468 EXPECT_TRUE(UpdateSearchState(overlay)); 1468 EXPECT_TRUE(UpdateSearchState(overlay));
1469 EXPECT_EQ(0, on_native_suggestions_calls_); 1469 EXPECT_EQ(0, on_native_suggestions_calls_);
1470 1470
1471 SetOmniboxTextAndWaitForOverlayToShow("railroad"); 1471 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("railroad"));
1472 1472
1473 EXPECT_EQ(overlay, instant()->GetOverlayContents()); 1473 EXPECT_EQ(overlay, instant()->GetOverlayContents());
1474 EXPECT_TRUE(UpdateSearchState(overlay)); 1474 EXPECT_TRUE(UpdateSearchState(overlay));
1475 EXPECT_EQ(1, on_native_suggestions_calls_); 1475 EXPECT_EQ(1, on_native_suggestions_calls_);
1476 } 1476 }
1477 1477
1478 // Test that the local NTP doesn't end up with the local overlay's URL. 1478 // Test that the local NTP doesn't end up with the local overlay's URL.
1479 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, LocalNTPIsNotLocalOverlay) { 1479 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, LocalNTPIsNotLocalOverlay) {
1480 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1480 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1481 1481
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 EXPECT_TRUE(tab1_helper->model()->top_bars_visible()); 1524 EXPECT_TRUE(tab1_helper->model()->top_bars_visible());
1525 1525
1526 // Select 1st tab and type in omnibox. We really want a partial-height 1526 // Select 1st tab and type in omnibox. We really want a partial-height
1527 // overlay, so that it doesn't get committed when switching away from this 1527 // overlay, so that it doesn't get committed when switching away from this
1528 // tab. However, the instant_extended.html used for tests always shows at 1528 // tab. However, the instant_extended.html used for tests always shows at
1529 // full height, though it doesn't commit the overlay when the omnibox text is 1529 // full height, though it doesn't commit the overlay when the omnibox text is
1530 // a URL and not a search. So we specifically set a URL as the omnibox text. 1530 // a URL and not a search. So we specifically set a URL as the omnibox text.
1531 // The overlay showing will trigger top bars in 1st tab to be hidden, but keep 1531 // The overlay showing will trigger top bars in 1st tab to be hidden, but keep
1532 // 2nd tab's visible. 1532 // 2nd tab's visible.
1533 browser()->tab_strip_model()->ActivateTabAt(0, true); 1533 browser()->tab_strip_model()->ActivateTabAt(0, true);
1534 SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/"); 1534 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/"));
1535 EXPECT_FALSE(tab0_helper->model()->top_bars_visible()); 1535 EXPECT_FALSE(tab0_helper->model()->top_bars_visible());
1536 EXPECT_TRUE(tab1_helper->model()->top_bars_visible()); 1536 EXPECT_TRUE(tab1_helper->model()->top_bars_visible());
1537 1537
1538 // Select 2nd tab, top bars of 1st tab should become visible, because its 1538 // Select 2nd tab, top bars of 1st tab should become visible, because its
1539 // overlay has been hidden. 1539 // overlay has been hidden.
1540 browser()->tab_strip_model()->ActivateTabAt(1, true); 1540 browser()->tab_strip_model()->ActivateTabAt(1, true);
1541 EXPECT_TRUE(tab0_helper->model()->top_bars_visible()); 1541 EXPECT_TRUE(tab0_helper->model()->top_bars_visible());
1542 EXPECT_TRUE(tab1_helper->model()->top_bars_visible()); 1542 EXPECT_TRUE(tab1_helper->model()->top_bars_visible());
1543 1543
1544 // Select back 1st tab, top bars visibility of both tabs should be the same 1544 // Select back 1st tab, top bars visibility of both tabs should be the same
1545 // as before. 1545 // as before.
1546 browser()->tab_strip_model()->ActivateTabAt(0, true); 1546 browser()->tab_strip_model()->ActivateTabAt(0, true);
1547 EXPECT_TRUE(tab0_helper->model()->top_bars_visible()); 1547 EXPECT_TRUE(tab0_helper->model()->top_bars_visible());
1548 EXPECT_TRUE(tab1_helper->model()->top_bars_visible()); 1548 EXPECT_TRUE(tab1_helper->model()->top_bars_visible());
1549 1549
1550 // Type in omnibox to trigger full-height overlay, which will trigger its top 1550 // Type in omnibox to trigger full-height overlay, which will trigger its top
1551 // bars to be hidden, but keep 2nd tab's visible. 1551 // bars to be hidden, but keep 2nd tab's visible.
1552 SetOmniboxTextAndWaitForOverlayToShow("query"); 1552 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
1553 EXPECT_FALSE(tab0_helper->model()->top_bars_visible()); 1553 EXPECT_FALSE(tab0_helper->model()->top_bars_visible());
1554 EXPECT_TRUE(tab1_helper->model()->top_bars_visible()); 1554 EXPECT_TRUE(tab1_helper->model()->top_bars_visible());
1555 1555
1556 // Select 2nd tab, its top bars should show, but top bars for 1st tab should 1556 // Select 2nd tab, its top bars should show, but top bars for 1st tab should
1557 // remain hidden, because the committed full-height overlay is still showing 1557 // remain hidden, because the committed full-height overlay is still showing
1558 // suggestions. 1558 // suggestions.
1559 browser()->tab_strip_model()->ActivateTabAt(1, true); 1559 browser()->tab_strip_model()->ActivateTabAt(1, true);
1560 EXPECT_FALSE(tab0_helper->model()->top_bars_visible()); 1560 EXPECT_FALSE(tab0_helper->model()->top_bars_visible());
1561 EXPECT_TRUE(tab1_helper->model()->top_bars_visible()); 1561 EXPECT_TRUE(tab1_helper->model()->top_bars_visible());
1562 } 1562 }
(...skipping 24 matching lines...) Expand all
1587 EXPECT_TRUE(found_bookmark_match); 1587 EXPECT_TRUE(found_bookmark_match);
1588 } 1588 }
1589 1589
1590 // Test that the omnibox's temporary text is reset when the popup is closed. 1590 // Test that the omnibox's temporary text is reset when the popup is closed.
1591 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, TemporaryTextResetWhenPopupClosed) { 1591 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, TemporaryTextResetWhenPopupClosed) {
1592 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1592 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1593 FocusOmniboxAndWaitForInstantExtendedSupport(); 1593 FocusOmniboxAndWaitForInstantExtendedSupport();
1594 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 1594 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
1595 1595
1596 // Show the overlay and arrow-down to a suggestion (this sets temporary text). 1596 // Show the overlay and arrow-down to a suggestion (this sets temporary text).
1597 SetOmniboxTextAndWaitForOverlayToShow("juju"); 1597 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("juju"));
1598 SendDownArrow(); 1598 SendDownArrow();
1599 1599
1600 EXPECT_TRUE(HasTemporaryText()); 1600 EXPECT_TRUE(HasTemporaryText());
1601 EXPECT_EQ("result 1", GetOmniboxText()); 1601 EXPECT_EQ("result 1", GetOmniboxText());
1602 1602
1603 // Click outside the omnibox (but not on the overlay), to make the omnibox 1603 // Click outside the omnibox (but not on the overlay), to make the omnibox
1604 // lose focus. Close the popup explicitly, to workaround test/toolkit issues. 1604 // lose focus. Close the popup explicitly, to workaround test/toolkit issues.
1605 ui_test_utils::ClickOnView(browser(), VIEW_ID_TOOLBAR); 1605 ui_test_utils::ClickOnView(browser(), VIEW_ID_TOOLBAR);
1606 omnibox()->CloseOmniboxPopup(); 1606 omnibox()->CloseOmniboxPopup();
1607 1607
(...skipping 11 matching lines...) Expand all
1619 } 1619 }
1620 1620
1621 // Test that autocomplete results aren't sent when the popup is closed. 1621 // Test that autocomplete results aren't sent when the popup is closed.
1622 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 1622 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
1623 NoAutocompleteResultsWhenPopupClosed) { 1623 NoAutocompleteResultsWhenPopupClosed) {
1624 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1624 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1625 FocusOmniboxAndWaitForInstantExtendedSupport(); 1625 FocusOmniboxAndWaitForInstantExtendedSupport();
1626 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 1626 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
1627 1627
1628 // Show the overlay and arrow-down to a suggestion (this sets temporary text). 1628 // Show the overlay and arrow-down to a suggestion (this sets temporary text).
1629 SetOmniboxTextAndWaitForOverlayToShow("thangam"); 1629 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("thangam"));
1630 SendDownArrow(); 1630 SendDownArrow();
1631 EXPECT_TRUE(HasTemporaryText()); 1631 EXPECT_TRUE(HasTemporaryText());
1632 1632
1633 EXPECT_TRUE(ExecuteScript("onChangeCalls = onNativeSuggestionsCalls = 0;")); 1633 EXPECT_TRUE(ExecuteScript("onChangeCalls = onNativeSuggestionsCalls = 0;"));
1634 1634
1635 content::WebContents* overlay = instant()->GetOverlayContents(); 1635 content::WebContents* overlay = instant()->GetOverlayContents();
1636 EXPECT_TRUE(UpdateSearchState(overlay)); 1636 EXPECT_TRUE(UpdateSearchState(overlay));
1637 EXPECT_EQ(0, on_change_calls_); 1637 EXPECT_EQ(0, on_change_calls_);
1638 EXPECT_EQ(0, on_native_suggestions_calls_); 1638 EXPECT_EQ(0, on_native_suggestions_calls_);
1639 1639
1640 // Click outside the omnibox (but not on the overlay), to make the omnibox 1640 // Click outside the omnibox (but not on the overlay), to make the omnibox
1641 // lose focus. Close the popup explicitly, to workaround test/toolkit issues. 1641 // lose focus. Close the popup explicitly, to workaround test/toolkit issues.
1642 ui_test_utils::ClickOnView(browser(), VIEW_ID_TOOLBAR); 1642 ui_test_utils::ClickOnView(browser(), VIEW_ID_TOOLBAR);
1643 omnibox()->CloseOmniboxPopup(); 1643 omnibox()->CloseOmniboxPopup();
1644 EXPECT_FALSE(HasTemporaryText()); 1644 EXPECT_FALSE(HasTemporaryText());
1645 1645
1646 EXPECT_EQ(overlay, instant()->GetOverlayContents()); 1646 EXPECT_EQ(overlay, instant()->GetOverlayContents());
1647 EXPECT_TRUE(UpdateSearchState(overlay)); 1647 EXPECT_TRUE(UpdateSearchState(overlay));
1648 EXPECT_EQ(0, on_change_calls_); 1648 EXPECT_EQ(0, on_change_calls_);
1649 EXPECT_EQ(0, on_native_suggestions_calls_); 1649 EXPECT_EQ(0, on_native_suggestions_calls_);
1650 } 1650 }
1651 1651
1652 // Test that suggestions are not accepted when unexpected. 1652 // Test that suggestions are not accepted when unexpected.
1653 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DeniesUnexpectedSuggestions) { 1653 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DeniesUnexpectedSuggestions) {
1654 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1654 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1655 FocusOmniboxAndWaitForInstantExtendedSupport(); 1655 FocusOmniboxAndWaitForInstantExtendedSupport();
1656 SetOmniboxTextAndWaitForOverlayToShow("chip"); 1656 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("chip"));
1657 SendDownArrow(); 1657 SendDownArrow();
1658 1658
1659 EXPECT_EQ("result 1", GetOmniboxText()); 1659 EXPECT_EQ("result 1", GetOmniboxText());
1660 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); 1660 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText());
1661 1661
1662 // Make the page send an unexpected suggestion. 1662 // Make the page send an unexpected suggestion.
1663 EXPECT_TRUE(ExecuteScript("suggestion = 'chippies';" 1663 EXPECT_TRUE(ExecuteScript("suggestion = 'chippies';"
1664 "handleOnChange();")); 1664 "handleOnChange();"));
1665 1665
1666 // Verify that the suggestion is ignored. 1666 // Verify that the suggestion is ignored.
1667 EXPECT_EQ("result 1", GetOmniboxText()); 1667 EXPECT_EQ("result 1", GetOmniboxText());
1668 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); 1668 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText());
1669 } 1669 }
1670 1670
1671 // Test that autocomplete results are cleared when the query is cleared. 1671 // Test that autocomplete results are cleared when the query is cleared.
1672 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EmptyAutocompleteResults) { 1672 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EmptyAutocompleteResults) {
1673 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1673 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1674 FocusOmniboxAndWaitForInstantExtendedSupport(); 1674 FocusOmniboxAndWaitForInstantExtendedSupport();
1675 1675
1676 // Type a URL, so that there's at least one autocomplete result (a "URL what 1676 // Type a URL, so that there's at least one autocomplete result (a "URL what
1677 // you typed" match). 1677 // you typed" match).
1678 SetOmniboxTextAndWaitForOverlayToShow("http://upsamina/"); 1678 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://upsamina/"));
1679 1679
1680 content::WebContents* overlay = instant()->GetOverlayContents(); 1680 content::WebContents* overlay = instant()->GetOverlayContents();
1681 1681
1682 int num_autocomplete_results = 0; 1682 int num_autocomplete_results = 0;
1683 EXPECT_TRUE(GetIntFromJS( 1683 EXPECT_TRUE(GetIntFromJS(
1684 overlay, 1684 overlay,
1685 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", 1685 "chrome.embeddedSearch.searchBox.nativeSuggestions.length",
1686 &num_autocomplete_results)); 1686 &num_autocomplete_results));
1687 EXPECT_LT(0, num_autocomplete_results); 1687 EXPECT_LT(0, num_autocomplete_results);
1688 1688
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 SendEscape(); 1728 SendEscape();
1729 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", 1729 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value",
1730 &query)); 1730 &query));
1731 EXPECT_EQ("", query); 1731 EXPECT_EQ("", query);
1732 EXPECT_EQ("", GetOmniboxText()); 1732 EXPECT_EQ("", GetOmniboxText());
1733 1733
1734 EXPECT_TRUE(UpdateSearchState(contents)); 1734 EXPECT_TRUE(UpdateSearchState(contents));
1735 EXPECT_LT(0, on_change_calls_); 1735 EXPECT_LT(0, on_change_calls_);
1736 EXPECT_EQ(0, submit_count_); 1736 EXPECT_EQ(0, submit_count_);
1737 } 1737 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_browsertest.cc ('k') | chrome/browser/ui/search/instant_extended_manual_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698