OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/instant/instant_controller.h" | 10 #include "chrome/browser/instant/instant_controller.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 #define MAYBE_SetSuggestionsValidJson DISABLED_SetSuggestionsValidJson | 41 #define MAYBE_SetSuggestionsValidJson DISABLED_SetSuggestionsValidJson |
42 #define MAYBE_SetSuggestionsInvalidSuggestions \ | 42 #define MAYBE_SetSuggestionsInvalidSuggestions \ |
43 DISABLED_SetSuggestionsInvalidSuggestions | 43 DISABLED_SetSuggestionsInvalidSuggestions |
44 #define MAYBE_SetSuggestionsEmptyJson DISABLED_SetSuggestionsEmptyJson | 44 #define MAYBE_SetSuggestionsEmptyJson DISABLED_SetSuggestionsEmptyJson |
45 #define MAYBE_SetSuggestionsEmptySuggestions \ | 45 #define MAYBE_SetSuggestionsEmptySuggestions \ |
46 DISABLED_SetSuggestionsEmptySuggestions | 46 DISABLED_SetSuggestionsEmptySuggestions |
47 #define MAYBE_SetSuggestionsEmptySuggestion \ | 47 #define MAYBE_SetSuggestionsEmptySuggestion \ |
48 DISABLED_SetSuggestionsEmptySuggestion | 48 DISABLED_SetSuggestionsEmptySuggestion |
49 #define MAYBE_ShowPreviewNonSearch DISABLED_ShowPreviewNonSearch | 49 #define MAYBE_ShowPreviewNonSearch DISABLED_ShowPreviewNonSearch |
50 #define MAYBE_NonSearchToSearch DISABLED_NonSearchToSearch | 50 #define MAYBE_NonSearchToSearch DISABLED_NonSearchToSearch |
51 #define MAYBE_SearchToNonSearch DISABLED_SearchToNonSearch | |
51 #define MAYBE_ValidHeight DISABLED_ValidHeight | 52 #define MAYBE_ValidHeight DISABLED_ValidHeight |
52 #define MAYBE_OnSubmitEvent DISABLED_OnSubmitEvent | 53 #define MAYBE_OnSubmitEvent DISABLED_OnSubmitEvent |
53 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent | 54 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent |
54 #define MAYBE_InstantCompleteNever DISABLED_InstantCompleteNever | 55 #define MAYBE_InstantCompleteNever DISABLED_InstantCompleteNever |
55 #define MAYBE_InstantCompleteDelayed DISABLED_InstantCompleteDelayed | 56 #define MAYBE_InstantCompleteDelayed DISABLED_InstantCompleteDelayed |
56 #define MAYBE_DontCrashOnBlockedJS DISABLED_DontCrashOnBlockedJS | 57 #define MAYBE_DontCrashOnBlockedJS DISABLED_DontCrashOnBlockedJS |
57 #define MAYBE_DontPersistSearchbox DISABLED_DontPersistSearchbox | 58 #define MAYBE_DontPersistSearchbox DISABLED_DontPersistSearchbox |
58 #define MAYBE_PreloadsInstant DISABLED_PreloadsInstant | 59 #define MAYBE_PreloadsInstant DISABLED_PreloadsInstant |
59 #define MAYBE_ExperimentEnabled DISABLED_ExperimentEnabled | 60 #define MAYBE_ExperimentEnabled DISABLED_ExperimentEnabled |
60 #else | 61 #else |
61 #define MAYBE_OnChangeEvent OnChangeEvent | 62 #define MAYBE_OnChangeEvent OnChangeEvent |
62 #define MAYBE_SetSuggestionsArrayOfStrings SetSuggestionsArrayOfStrings | 63 #define MAYBE_SetSuggestionsArrayOfStrings SetSuggestionsArrayOfStrings |
63 #define MAYBE_SetSuggestionsEmptyArray SetSuggestionsEmptyArray | 64 #define MAYBE_SetSuggestionsEmptyArray SetSuggestionsEmptyArray |
64 #define MAYBE_SetSuggestionsValidJson SetSuggestionsValidJson | 65 #define MAYBE_SetSuggestionsValidJson SetSuggestionsValidJson |
65 #define MAYBE_SetSuggestionsInvalidSuggestions SetSuggestionsInvalidSuggestions | 66 #define MAYBE_SetSuggestionsInvalidSuggestions SetSuggestionsInvalidSuggestions |
66 #define MAYBE_SetSuggestionsEmptyJson SetSuggestionsEmptyJson | 67 #define MAYBE_SetSuggestionsEmptyJson SetSuggestionsEmptyJson |
67 #define MAYBE_SetSuggestionsEmptySuggestions SetSuggestionsEmptySuggestions | 68 #define MAYBE_SetSuggestionsEmptySuggestions SetSuggestionsEmptySuggestions |
68 #define MAYBE_SetSuggestionsEmptySuggestion SetSuggestionsEmptySuggestion | 69 #define MAYBE_SetSuggestionsEmptySuggestion SetSuggestionsEmptySuggestion |
69 #define MAYBE_ShowPreviewNonSearch ShowPreviewNonSearch | 70 #define MAYBE_ShowPreviewNonSearch ShowPreviewNonSearch |
70 #define MAYBE_NonSearchToSearch NonSearchToSearch | 71 #define MAYBE_NonSearchToSearch NonSearchToSearch |
72 #define MAYBE_SearchToNonSearch SearchToNonSearch | |
71 #define MAYBE_ValidHeight ValidHeight | 73 #define MAYBE_ValidHeight ValidHeight |
72 #define MAYBE_OnSubmitEvent OnSubmitEvent | 74 #define MAYBE_OnSubmitEvent OnSubmitEvent |
73 #define MAYBE_OnCancelEvent OnCancelEvent | 75 #define MAYBE_OnCancelEvent OnCancelEvent |
74 #define MAYBE_InstantCompleteNever InstantCompleteNever | 76 #define MAYBE_InstantCompleteNever InstantCompleteNever |
75 #define MAYBE_InstantCompleteDelayed InstantCompleteDelayed | 77 #define MAYBE_InstantCompleteDelayed InstantCompleteDelayed |
76 #define MAYBE_DontCrashOnBlockedJS DontCrashOnBlockedJS | 78 #define MAYBE_DontCrashOnBlockedJS DontCrashOnBlockedJS |
77 #define MAYBE_DontPersistSearchbox DontPersistSearchbox | 79 #define MAYBE_DontPersistSearchbox DontPersistSearchbox |
78 #define MAYBE_PreloadsInstant PreloadsInstant | 80 #define MAYBE_PreloadsInstant PreloadsInstant |
79 #define MAYBE_ExperimentEnabled ExperimentEnabled | 81 #define MAYBE_ExperimentEnabled ExperimentEnabled |
80 #endif | 82 #endif |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 ASSERT_TRUE(preview_); | 167 ASSERT_TRUE(preview_); |
166 ui_test_utils::WaitForNavigation(&preview_->controller()); | 168 ui_test_utils::WaitForNavigation(&preview_->controller()); |
167 } | 169 } |
168 | 170 |
169 // Wait for instant to load and ensure it is in the state we expect. | 171 // Wait for instant to load and ensure it is in the state we expect. |
170 void SetupPreview() { | 172 void SetupPreview() { |
171 // Wait for the preview to navigate. | 173 // Wait for the preview to navigate. |
172 WaitForPreviewToNavigate(); | 174 WaitForPreviewToNavigate(); |
173 | 175 |
174 ASSERT_FALSE(browser()->instant()->is_displayable()); | 176 ASSERT_FALSE(browser()->instant()->is_displayable()); |
175 ASSERT_TRUE(browser()->instant()->is_active()); | 177 ASSERT_TRUE(HasPreview()); |
176 | 178 |
177 // When the page loads, the initial searchBox values are set and only a | 179 // When the page loads, the initial searchBox values are set and only a |
178 // resize will have been sent. | 180 // resize will have been sent. |
179 ASSERT_EQ("true 0 0 0 true d false d false 1 1", | 181 ASSERT_EQ("true 0 0 0 true d false d false 1 1", |
180 GetSearchStateAsString(preview_, false)); | 182 GetSearchStateAsString(preview_, false)); |
181 } | 183 } |
182 | 184 |
183 void SetLocationBarText(const std::string& text) { | 185 void SetLocationBarText(const std::string& text) { |
184 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | 186 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); |
185 ui_test_utils::WindowedNotificationObserver controller_shown_observer( | 187 ui_test_utils::WindowedNotificationObserver controller_shown_observer( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 bool GetBoolFromJavascript(TabContents* tab_contents, | 238 bool GetBoolFromJavascript(TabContents* tab_contents, |
237 const std::string& function, | 239 const std::string& function, |
238 bool* result) { | 240 bool* result) { |
239 std::string script = StringPrintf( | 241 std::string script = StringPrintf( |
240 "window.domAutomationController.send(%s)", function.c_str()); | 242 "window.domAutomationController.send(%s)", function.c_str()); |
241 return ui_test_utils::ExecuteJavaScriptAndExtractBool( | 243 return ui_test_utils::ExecuteJavaScriptAndExtractBool( |
242 tab_contents->render_view_host(), | 244 tab_contents->render_view_host(), |
243 std::wstring(), UTF8ToWide(script), result); | 245 std::wstring(), UTF8ToWide(script), result); |
244 } | 246 } |
245 | 247 |
248 bool HasPreview() { | |
249 return browser()->instant()->GetPreviewContents() != NULL; | |
250 } | |
251 | |
246 // Returns the state of the search box as a string. This consists of the | 252 // Returns the state of the search box as a string. This consists of the |
247 // following: | 253 // following: |
248 // window.chrome.sv | 254 // window.chrome.sv |
249 // window.onsubmitcalls | 255 // window.onsubmitcalls |
250 // window.oncancelcalls | 256 // window.oncancelcalls |
251 // window.onchangecalls | 257 // window.onchangecalls |
252 // 'true' if window.onresizecalls has been sent, otherwise false. | 258 // 'true' if window.onresizecalls has been sent, otherwise false. |
253 // window.beforeLoadSearchBox.value | 259 // window.beforeLoadSearchBox.value |
254 // window.beforeLoadSearchBox.verbatim | 260 // window.beforeLoadSearchBox.verbatim |
255 // window.chrome.searchBox.value | 261 // window.chrome.searchBox.value |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 } | 504 } |
499 | 505 |
500 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_ShowPreviewNonSearch) { | 506 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_ShowPreviewNonSearch) { |
501 ASSERT_TRUE(test_server()->Start()); | 507 ASSERT_TRUE(test_server()->Start()); |
502 EnableInstant(); | 508 EnableInstant(); |
503 GURL url(test_server()->GetURL("files/instant/empty.html")); | 509 GURL url(test_server()->GetURL("files/instant/empty.html")); |
504 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | 510 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); |
505 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); | 511 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); |
506 | 512 |
507 // The preview should not be active or showing. | 513 // The preview should not be active or showing. |
508 ASSERT_FALSE(browser()->instant()->is_active()); | 514 ASSERT_FALSE(HasPreview()); |
509 ASSERT_FALSE(browser()->instant()->is_displayable()); | 515 ASSERT_FALSE(browser()->instant()->is_displayable()); |
510 ASSERT_FALSE(browser()->instant()->IsCurrent()); | 516 ASSERT_FALSE(browser()->instant()->IsCurrent()); |
511 ASSERT_EQ(NULL, browser()->instant()->GetPreviewContents()); | 517 ASSERT_EQ(NULL, browser()->instant()->GetPreviewContents()); |
512 } | 518 } |
513 | 519 |
514 // Transition from non-search to search and make sure everything is shown | 520 // Transition from non-search to search and make sure everything is shown |
515 // correctly. | 521 // correctly. |
516 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NonSearchToSearch) { | 522 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NonSearchToSearch) { |
517 ASSERT_TRUE(test_server()->Start()); | 523 ASSERT_TRUE(test_server()->Start()); |
518 EnableInstant(); | 524 EnableInstant(); |
519 GURL url(test_server()->GetURL("files/instant/empty.html")); | 525 GURL url(test_server()->GetURL("files/instant/empty.html")); |
520 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | 526 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); |
521 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); | 527 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); |
522 // The preview not should be active and not showing. | 528 // The preview not should be active and not showing. |
523 ASSERT_FALSE(browser()->instant()->is_active()); | 529 ASSERT_FALSE(HasPreview()); |
524 ASSERT_FALSE(browser()->instant()->is_displayable()); | 530 ASSERT_FALSE(browser()->instant()->is_displayable()); |
525 ASSERT_EQ(NULL, browser()->instant()->GetPreviewContents()); | 531 ASSERT_EQ(NULL, browser()->instant()->GetPreviewContents()); |
526 | 532 |
527 // Now type in some search text. | 533 // Now type in some search text. |
528 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); | 534 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); |
529 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("def")); | 535 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("def")); |
530 | 536 |
531 // Wait for the preview to navigate. | 537 // Wait for the preview to navigate. |
532 ASSERT_NO_FATAL_FAILURE(WaitForPreviewToNavigate()); | 538 ASSERT_NO_FATAL_FAILURE(WaitForPreviewToNavigate()); |
533 | 539 |
534 // The controller is still determining if the provider really supports | 540 // The controller is still determining if the provider really supports |
535 // instant. | 541 // instant. |
536 TabContentsWrapper* current_tab = browser()->instant()->GetPreviewContents(); | 542 TabContentsWrapper* current_tab = browser()->instant()->GetPreviewContents(); |
537 ASSERT_TRUE(current_tab); | 543 ASSERT_TRUE(current_tab); |
538 | 544 |
539 // Instant should be active. | 545 // Instant should be active. |
540 EXPECT_TRUE(browser()->instant()->is_active()); | 546 EXPECT_TRUE(HasPreview()); |
541 EXPECT_FALSE(browser()->instant()->is_displayable()); | 547 EXPECT_FALSE(browser()->instant()->is_displayable()); |
542 | 548 |
543 // Because we're waiting on the page, instant isn't current. | 549 // Because we're waiting on the page, instant isn't current. |
544 ASSERT_FALSE(browser()->instant()->IsCurrent()); | 550 ASSERT_FALSE(browser()->instant()->IsCurrent()); |
545 | 551 |
546 // Bounce a message to the renderer so that we know the instant has gotten a | 552 // Bounce a message to the renderer so that we know the instant has gotten a |
547 // response back from the renderer as to whether the page supports instant. | 553 // response back from the renderer as to whether the page supports instant. |
548 ASSERT_NO_FATAL_FAILURE(WaitForMessageToBeProcessedByRenderer(current_tab)); | 554 ASSERT_NO_FATAL_FAILURE(WaitForMessageToBeProcessedByRenderer(current_tab)); |
549 | 555 |
550 // Reset the user text so that the page is told the text changed. We should be | 556 // Reset the user text so that the page is told the text changed. We should be |
551 // able to nuke this once 66104 is fixed. | 557 // able to nuke this once 66104 is fixed. |
552 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("defg")); | 558 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("defg")); |
553 | 559 |
554 // Wait for the renderer to process it. | 560 // Wait for the renderer to process it. |
555 ASSERT_NO_FATAL_FAILURE(WaitForMessageToBeProcessedByRenderer(current_tab)); | 561 ASSERT_NO_FATAL_FAILURE(WaitForMessageToBeProcessedByRenderer(current_tab)); |
556 | 562 |
557 // We should have gotten a response back from the renderer that resulted in | 563 // We should have gotten a response back from the renderer that resulted in |
558 // committing. | 564 // committing. |
559 ASSERT_TRUE(browser()->instant()->is_active()); | 565 ASSERT_TRUE(HasPreview()); |
560 ASSERT_TRUE(browser()->instant()->is_displayable()); | 566 ASSERT_TRUE(browser()->instant()->is_displayable()); |
561 TabContentsWrapper* new_tab = browser()->instant()->GetPreviewContents(); | 567 TabContentsWrapper* new_tab = browser()->instant()->GetPreviewContents(); |
562 ASSERT_TRUE(new_tab); | 568 ASSERT_TRUE(new_tab); |
563 RenderWidgetHostView* new_rwhv = | 569 RenderWidgetHostView* new_rwhv = |
564 new_tab->tab_contents()->GetRenderWidgetHostView(); | 570 new_tab->tab_contents()->GetRenderWidgetHostView(); |
565 ASSERT_TRUE(new_rwhv); | 571 ASSERT_TRUE(new_rwhv); |
566 ASSERT_TRUE(new_rwhv->IsShowing()); | 572 ASSERT_TRUE(new_rwhv->IsShowing()); |
567 } | 573 } |
568 | 574 |
575 // Transition from search to non-search and make sure instant isn't displayable. | |
sreeram
2011/10/14 20:07:32
Perhaps add the bug reference (http://crbug.com/10
| |
576 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_SearchToNonSearch) { | |
577 ASSERT_TRUE(test_server()->Start()); | |
578 EnableInstant(); | |
579 GURL url(test_server()->GetURL("files/instant/empty.html")); | |
580 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | |
581 | |
582 // Type in some search text. | |
583 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); | |
584 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("def")); | |
585 | |
586 // Load a non search url. Don't wait for the preview to navigate. It'll still | |
587 // end up loading in the background. | |
588 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); | |
589 | |
590 // Wait for the preview to navigate. | |
591 ASSERT_NO_FATAL_FAILURE(WaitForPreviewToNavigate()); | |
592 | |
593 // Send onchange so that the page sends up suggestions. | |
594 TabContentsWrapper* current_tab = browser()->instant()->GetPreviewContents(); | |
595 ui_test_utils::ExecuteJavaScript( | |
596 current_tab->tab_contents()->render_view_host(), std::wstring(), | |
597 L"window.chrome.searchBox.onchange();"); | |
598 ASSERT_NO_FATAL_FAILURE(WaitForMessageToBeProcessedByRenderer(current_tab)); | |
599 | |
600 // Instant should be active, but not displaying | |
601 EXPECT_TRUE(HasPreview()); | |
602 EXPECT_FALSE(browser()->instant()->is_displayable()); | |
sreeram
2011/10/14 20:07:32
Nice test, thanks!
| |
603 } | |
604 | |
569 // Makes sure that if the server doesn't support the instant API we don't show | 605 // Makes sure that if the server doesn't support the instant API we don't show |
570 // anything. | 606 // anything. |
571 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_SearchServerDoesntSupportInstant) { | 607 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_SearchServerDoesntSupportInstant) { |
572 ASSERT_TRUE(test_server()->Start()); | 608 ASSERT_TRUE(test_server()->Start()); |
573 EnableInstant(); | 609 EnableInstant(); |
574 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("empty.html")); | 610 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("empty.html")); |
575 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | 611 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); |
576 | 612 |
577 ui_test_utils::WindowedNotificationObserver tab_closed_observer( | 613 ui_test_utils::WindowedNotificationObserver tab_closed_observer( |
578 content::NOTIFICATION_TAB_CLOSED, | 614 content::NOTIFICATION_TAB_CLOSED, |
579 NotificationService::AllSources()); | 615 NotificationService::AllSources()); |
580 | 616 |
581 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("d")); | 617 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("d")); |
582 ASSERT_TRUE(browser()->instant()); | 618 ASSERT_TRUE(browser()->instant()); |
583 // But because we're waiting to determine if the page really supports instant | 619 // But because we're waiting to determine if the page really supports instant |
584 // we shouldn't be showing the preview. | 620 // we shouldn't be showing the preview. |
585 EXPECT_FALSE(browser()->instant()->is_displayable()); | 621 EXPECT_FALSE(browser()->instant()->is_displayable()); |
586 // But instant should still be active. | 622 // But instant should still be active. |
587 EXPECT_TRUE(browser()->instant()->is_active()); | 623 EXPECT_TRUE(HasPreview()); |
588 | 624 |
589 // When the response comes back that the page doesn't support instant the tab | 625 // When the response comes back that the page doesn't support instant the tab |
590 // should be closed. | 626 // should be closed. |
591 tab_closed_observer.Wait(); | 627 tab_closed_observer.Wait(); |
592 EXPECT_FALSE(browser()->instant()->is_displayable()); | 628 EXPECT_FALSE(browser()->instant()->is_displayable()); |
593 EXPECT_TRUE(browser()->instant()->is_active()); | 629 EXPECT_FALSE(HasPreview()); |
594 EXPECT_FALSE(browser()->instant()->IsCurrent()); | 630 EXPECT_FALSE(browser()->instant()->IsCurrent()); |
595 } | 631 } |
596 | 632 |
597 // Verifies that Instant previews aren't shown for crash URLs. | 633 // Verifies that Instant previews aren't shown for crash URLs. |
598 IN_PROC_BROWSER_TEST_F(InstantTest, CrashUrlCancelsInstant) { | 634 IN_PROC_BROWSER_TEST_F(InstantTest, CrashUrlCancelsInstant) { |
599 ASSERT_TRUE(test_server()->Start()); | 635 ASSERT_TRUE(test_server()->Start()); |
600 EnableInstant(); | 636 EnableInstant(); |
601 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("empty.html")); | 637 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("empty.html")); |
602 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | 638 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); |
603 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("chrome://crash")); | 639 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("chrome://crash")); |
604 ASSERT_TRUE(browser()->instant()); | 640 ASSERT_TRUE(browser()->instant()); |
605 EXPECT_FALSE(browser()->instant()->is_displayable()); | 641 EXPECT_FALSE(browser()->instant()->is_displayable()); |
606 } | 642 } |
607 | 643 |
608 // Verifies transitioning from loading a non-search string to a search string | 644 // Verifies transitioning from loading a non-search string to a search string |
609 // with the provider not supporting instant works (meaning we don't display | 645 // with the provider not supporting instant works (meaning we don't display |
610 // anything). | 646 // anything). |
611 IN_PROC_BROWSER_TEST_F(InstantTest, | 647 IN_PROC_BROWSER_TEST_F(InstantTest, |
612 MAYBE_NonSearchToSearchDoesntSupportInstant) { | 648 MAYBE_NonSearchToSearchDoesntSupportInstant) { |
613 ASSERT_TRUE(test_server()->Start()); | 649 ASSERT_TRUE(test_server()->Start()); |
614 EnableInstant(); | 650 EnableInstant(); |
615 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("empty.html")); | 651 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("empty.html")); |
616 GURL url(test_server()->GetURL("files/instant/empty.html")); | 652 GURL url(test_server()->GetURL("files/instant/empty.html")); |
617 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | 653 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); |
618 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); | 654 location_bar_->location_entry()->SetUserText(UTF8ToUTF16(url.spec())); |
619 // The preview should not be showing or active. | 655 // The preview should not be showing or active. |
620 EXPECT_FALSE(browser()->instant()->is_displayable()); | 656 EXPECT_FALSE(browser()->instant()->is_displayable()); |
621 EXPECT_FALSE(browser()->instant()->is_active()); | 657 EXPECT_FALSE(HasPreview()); |
622 | 658 |
623 ui_test_utils::WindowedNotificationObserver tab_closed_observer( | 659 ui_test_utils::WindowedNotificationObserver tab_closed_observer( |
624 content::NOTIFICATION_TAB_CLOSED, | 660 content::NOTIFICATION_TAB_CLOSED, |
625 NotificationService::AllSources()); | 661 NotificationService::AllSources()); |
626 | 662 |
627 // Now type in some search text. | 663 // Now type in some search text. |
628 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("d")); | 664 location_bar_->location_entry()->SetUserText(ASCIIToUTF16("d")); |
629 | 665 |
630 // Instant should be active. | 666 // Instant should be active. |
631 ASSERT_TRUE(browser()->instant()->is_active()); | 667 ASSERT_TRUE(HasPreview()); |
632 // Instant should not be current (it's still loading). | 668 // Instant should not be current (it's still loading). |
633 EXPECT_FALSE(browser()->instant()->IsCurrent()); | 669 EXPECT_FALSE(browser()->instant()->IsCurrent()); |
634 | 670 |
635 // When the response comes back that the page doesn't support instant the tab | 671 // When the response comes back that the page doesn't support instant the tab |
636 // should be closed. | 672 // should be closed. |
637 tab_closed_observer.Wait(); | 673 tab_closed_observer.Wait(); |
638 EXPECT_FALSE(browser()->instant()->is_displayable()); | 674 EXPECT_FALSE(browser()->instant()->is_displayable()); |
639 // But because the omnibox is still open, instant should be active. | 675 EXPECT_FALSE(HasPreview()); |
640 EXPECT_TRUE(browser()->instant()->is_active()); | |
641 EXPECT_FALSE(browser()->instant()->is_displayable()); | |
642 EXPECT_FALSE(browser()->instant()->IsCurrent()); | 676 EXPECT_FALSE(browser()->instant()->IsCurrent()); |
643 EXPECT_EQ(NULL, browser()->instant()->GetPreviewContents()); | 677 EXPECT_EQ(NULL, browser()->instant()->GetPreviewContents()); |
644 } | 678 } |
645 | 679 |
646 // Verifies the page was told a non-zero height. | 680 // Verifies the page was told a non-zero height. |
647 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_ValidHeight) { | 681 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_ValidHeight) { |
648 ASSERT_TRUE(test_server()->Start()); | 682 ASSERT_TRUE(test_server()->Start()); |
649 EnableInstant(); | 683 EnableInstant(); |
650 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); | 684 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); |
651 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); | 685 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); |
(...skipping 24 matching lines...) Expand all Loading... | |
676 | 710 |
677 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 711 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
678 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); | 712 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); |
679 ASSERT_NO_FATAL_FAILURE(SetupPreview()); | 713 ASSERT_NO_FATAL_FAILURE(SetupPreview()); |
680 | 714 |
681 ASSERT_NO_FATAL_FAILURE(SetLocationBarText("def")); | 715 ASSERT_NO_FATAL_FAILURE(SetLocationBarText("def")); |
682 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN)); | 716 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN)); |
683 | 717 |
684 // Check that the preview contents have been committed. | 718 // Check that the preview contents have been committed. |
685 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); | 719 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); |
686 ASSERT_FALSE(browser()->instant()->is_active()); | 720 ASSERT_FALSE(HasPreview()); |
687 TabContents* contents = browser()->GetSelectedTabContents(); | 721 TabContents* contents = browser()->GetSelectedTabContents(); |
688 ASSERT_TRUE(contents); | 722 ASSERT_TRUE(contents); |
689 | 723 |
690 // We should have two entries. One corresponding to the page the user was | 724 // We should have two entries. One corresponding to the page the user was |
691 // first on, and one for the search page. | 725 // first on, and one for the search page. |
692 ASSERT_EQ(2, contents->controller().entry_count()); | 726 ASSERT_EQ(2, contents->controller().entry_count()); |
693 | 727 |
694 // Check that the value is reflected and onsubmit is called. | 728 // Check that the value is reflected and onsubmit is called. |
695 EXPECT_EQ("true 1 0 1 true d false defghi true 3 3", | 729 EXPECT_EQ("true 1 0 1 true d false defghi true 3 3", |
696 GetSearchStateAsString(preview_, true)); | 730 GetSearchStateAsString(preview_, true)); |
(...skipping 12 matching lines...) Expand all Loading... | |
709 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 743 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
710 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); | 744 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); |
711 ASSERT_NO_FATAL_FAILURE(SetupPreview()); | 745 ASSERT_NO_FATAL_FAILURE(SetupPreview()); |
712 | 746 |
713 ASSERT_NO_FATAL_FAILURE(SetLocationBarText("def")); | 747 ASSERT_NO_FATAL_FAILURE(SetLocationBarText("def")); |
714 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(), | 748 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(), |
715 VIEW_ID_TAB_CONTAINER)); | 749 VIEW_ID_TAB_CONTAINER)); |
716 | 750 |
717 // Check that the preview contents has been committed. | 751 // Check that the preview contents has been committed. |
718 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); | 752 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); |
719 ASSERT_FALSE(browser()->instant()->is_active()); | 753 ASSERT_FALSE(HasPreview()); |
720 TabContents* contents = browser()->GetSelectedTabContents(); | 754 TabContents* contents = browser()->GetSelectedTabContents(); |
721 ASSERT_TRUE(contents); | 755 ASSERT_TRUE(contents); |
722 | 756 |
723 // Check that the value is reflected and oncancel is called. | 757 // Check that the value is reflected and oncancel is called. |
724 EXPECT_EQ("true 0 1 1 true d false def false 3 3", | 758 EXPECT_EQ("true 0 1 1 true d false def false 3 3", |
725 GetSearchStateAsString(preview_, true)); | 759 GetSearchStateAsString(preview_, true)); |
726 | 760 |
727 // Make sure the searchbox values were reset. | 761 // Make sure the searchbox values were reset. |
728 EXPECT_EQ("true 0 1 1 true d false false 0 0", | 762 EXPECT_EQ("true 0 1 1 true d false false 0 0", |
729 GetSearchStateAsString(preview_, false)); | 763 GetSearchStateAsString(preview_, false)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 | 824 |
791 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 825 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
792 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); | 826 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); |
793 ASSERT_NO_FATAL_FAILURE(SetupPreview()); | 827 ASSERT_NO_FATAL_FAILURE(SetupPreview()); |
794 | 828 |
795 ASSERT_NO_FATAL_FAILURE(SetLocationBarText("def")); | 829 ASSERT_NO_FATAL_FAILURE(SetLocationBarText("def")); |
796 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN)); | 830 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN)); |
797 | 831 |
798 // Check that the preview contents have been committed. | 832 // Check that the preview contents have been committed. |
799 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); | 833 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); |
800 ASSERT_FALSE(browser()->instant()->is_active()); | 834 ASSERT_FALSE(HasPreview()); |
801 | 835 |
802 TabContents* contents = browser()->GetSelectedTabContents(); | 836 TabContents* contents = browser()->GetSelectedTabContents(); |
803 ASSERT_TRUE(contents); | 837 ASSERT_TRUE(contents); |
804 | 838 |
805 // Navigate to a new URL. This should reset the searchbox values. | 839 // Navigate to a new URL. This should reset the searchbox values. |
806 ui_test_utils::NavigateToURL( | 840 ui_test_utils::NavigateToURL( |
807 browser(), | 841 browser(), |
808 GURL(test_server()->GetURL("files/instant/empty.html"))); | 842 GURL(test_server()->GetURL("files/instant/empty.html"))); |
809 bool result; | 843 bool result; |
810 ASSERT_TRUE(GetBoolFromJavascript( | 844 ASSERT_TRUE(GetBoolFromJavascript( |
(...skipping 26 matching lines...) Expand all Loading... | |
837 NotificationService::AllSources()); | 871 NotificationService::AllSources()); |
838 | 872 |
839 // Focusing the omnibox should cause instant to be preloaded. | 873 // Focusing the omnibox should cause instant to be preloaded. |
840 FindLocationBar(); | 874 FindLocationBar(); |
841 location_bar_->FocusLocation(false); | 875 location_bar_->FocusLocation(false); |
842 TabContentsWrapper* tab_contents = browser()->instant()->GetPreviewContents(); | 876 TabContentsWrapper* tab_contents = browser()->instant()->GetPreviewContents(); |
843 EXPECT_TRUE(tab_contents); | 877 EXPECT_TRUE(tab_contents); |
844 | 878 |
845 instant_support_observer.Wait(); | 879 instant_support_observer.Wait(); |
846 | 880 |
847 // However, instant should still not be active. | 881 // Instant should have a preview, but not display it. |
848 EXPECT_FALSE(browser()->instant()->is_active()); | 882 EXPECT_TRUE(HasPreview()); |
849 EXPECT_FALSE(browser()->instant()->is_displayable()); | 883 EXPECT_FALSE(browser()->instant()->is_displayable()); |
850 | 884 |
851 // Adding a new tab shouldn't delete (or recreate) the TabContentsWrapper. | 885 // Adding a new tab shouldn't delete (or recreate) the TabContentsWrapper. |
852 AddBlankTabAndShow(browser()); | 886 AddBlankTabAndShow(browser()); |
853 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); | 887 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); |
854 | 888 |
855 // Doing a search should still use the same loader for the preview. | 889 // Doing a search should still use the same loader for the preview. |
856 SetLocationBarText("def"); | 890 SetLocationBarText("def"); |
857 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); | 891 EXPECT_EQ(tab_contents, browser()->instant()->GetPreviewContents()); |
858 | 892 |
859 // Verify that the preview is in fact showing instant search. | 893 // Verify that the preview is in fact showing instant search. |
860 EXPECT_TRUE(browser()->instant()->is_active()); | 894 EXPECT_TRUE(HasPreview()); |
861 EXPECT_TRUE(browser()->instant()->is_displayable()); | 895 EXPECT_TRUE(browser()->instant()->is_displayable()); |
862 EXPECT_TRUE(browser()->instant()->IsCurrent()); | 896 EXPECT_TRUE(browser()->instant()->IsCurrent()); |
863 } | 897 } |
864 | 898 |
865 // Tests the INSTANT experiment of the field trial. | 899 // Tests the INSTANT experiment of the field trial. |
866 class InstantFieldTrialInstantTest : public InstantTest { | 900 class InstantFieldTrialInstantTest : public InstantTest { |
867 public: | 901 public: |
868 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 902 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
869 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, | 903 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, |
870 switches::kInstantFieldTrialInstant); | 904 switches::kInstantFieldTrialInstant); |
871 } | 905 } |
872 }; | 906 }; |
873 | 907 |
874 // Tests that instant is active, even without calling EnableInstant(). | 908 // Tests that instant is active, even without calling EnableInstant(). |
875 IN_PROC_BROWSER_TEST_F(InstantFieldTrialInstantTest, MAYBE_ExperimentEnabled) { | 909 IN_PROC_BROWSER_TEST_F(InstantFieldTrialInstantTest, MAYBE_ExperimentEnabled) { |
876 // Check that instant is enabled, despite not setting the preference. | 910 // Check that instant is enabled, despite not setting the preference. |
877 Profile* profile = browser()->profile(); | 911 Profile* profile = browser()->profile(); |
878 EXPECT_FALSE(profile->GetPrefs()->GetBoolean(prefs::kInstantEnabled)); | 912 EXPECT_FALSE(profile->GetPrefs()->GetBoolean(prefs::kInstantEnabled)); |
879 EXPECT_TRUE(InstantController::IsEnabled(profile)); | 913 EXPECT_TRUE(InstantController::IsEnabled(profile)); |
880 | 914 |
881 ASSERT_TRUE(test_server()->Start()); | 915 ASSERT_TRUE(test_server()->Start()); |
882 SetupInstantProvider("search.html"); | 916 SetupInstantProvider("search.html"); |
883 SetupLocationBar(); | 917 SetupLocationBar(); |
884 SetupPreview(); | 918 SetupPreview(); |
885 SetLocationBarText("def"); | 919 SetLocationBarText("def"); |
886 | 920 |
887 // Check that instant is active and showing a preview. | 921 // Check that instant is active and showing a preview. |
888 EXPECT_TRUE(browser()->instant()->is_active()); | 922 EXPECT_TRUE(HasPreview()); |
889 EXPECT_TRUE(browser()->instant()->is_displayable()); | 923 EXPECT_TRUE(browser()->instant()->is_displayable()); |
890 EXPECT_TRUE(browser()->instant()->IsCurrent()); | 924 EXPECT_TRUE(browser()->instant()->IsCurrent()); |
891 } | 925 } |
892 | 926 |
893 // Tests the HIDDEN experiment of the field trial. | 927 // Tests the HIDDEN experiment of the field trial. |
894 class InstantFieldTrialHiddenTest : public InstantTest { | 928 class InstantFieldTrialHiddenTest : public InstantTest { |
895 public: | 929 public: |
896 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 930 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
897 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, | 931 command_line->AppendSwitchASCII(switches::kInstantFieldTrial, |
898 switches::kInstantFieldTrialHidden); | 932 switches::kInstantFieldTrialHidden); |
(...skipping 13 matching lines...) Expand all Loading... | |
912 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, | 946 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, |
913 NotificationService::AllSources()); | 947 NotificationService::AllSources()); |
914 SetupLocationBar(); | 948 SetupLocationBar(); |
915 WaitForPreviewToNavigate(); | 949 WaitForPreviewToNavigate(); |
916 instant_support_observer.Wait(); | 950 instant_support_observer.Wait(); |
917 | 951 |
918 // Type into the omnibox, but don't press <Enter> yet. | 952 // Type into the omnibox, but don't press <Enter> yet. |
919 location_bar_->location_entry()->SetUserText(UTF8ToUTF16("def")); | 953 location_bar_->location_entry()->SetUserText(UTF8ToUTF16("def")); |
920 | 954 |
921 // Check that instant is active, but the preview is not showing. | 955 // Check that instant is active, but the preview is not showing. |
922 EXPECT_TRUE(browser()->instant()->is_active()); | 956 EXPECT_TRUE(HasPreview()); |
923 EXPECT_FALSE(browser()->instant()->is_displayable()); | 957 EXPECT_FALSE(browser()->instant()->is_displayable()); |
924 EXPECT_FALSE(browser()->instant()->IsCurrent()); | 958 EXPECT_FALSE(browser()->instant()->IsCurrent()); |
925 | 959 |
926 TabContentsWrapper* tab_contents = browser()->instant()->GetPreviewContents(); | 960 TabContentsWrapper* tab_contents = browser()->instant()->GetPreviewContents(); |
927 EXPECT_TRUE(tab_contents); | 961 EXPECT_TRUE(tab_contents); |
928 | 962 |
929 // Press <Enter> in the omnibox, causing the preview to be committed. | 963 // Press <Enter> in the omnibox, causing the preview to be committed. |
930 SendKey(ui::VKEY_RETURN); | 964 SendKey(ui::VKEY_RETURN); |
931 | 965 |
932 // The preview contents should now be the active tab contents. | 966 // The preview contents should now be the active tab contents. |
933 EXPECT_FALSE(browser()->instant()->GetPreviewContents()); | 967 EXPECT_FALSE(browser()->instant()->GetPreviewContents()); |
934 EXPECT_FALSE(browser()->instant()->is_active()); | 968 EXPECT_FALSE(HasPreview()); |
935 EXPECT_FALSE(browser()->instant()->is_displayable()); | 969 EXPECT_FALSE(browser()->instant()->is_displayable()); |
936 EXPECT_FALSE(browser()->instant()->IsCurrent()); | 970 EXPECT_FALSE(browser()->instant()->IsCurrent()); |
937 EXPECT_EQ(tab_contents, browser()->GetSelectedTabContentsWrapper()); | 971 EXPECT_EQ(tab_contents, browser()->GetSelectedTabContentsWrapper()); |
938 } | 972 } |
OLD | NEW |