| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 8 #include "chrome/browser/history/history.h" | 8 #include "chrome/browser/history/history.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/instant/instant_controller.h" | 10 #include "chrome/browser/instant/instant_controller.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 int onsubmitcalls_; | 138 int onsubmitcalls_; |
| 139 int oncancelcalls_; | 139 int oncancelcalls_; |
| 140 int onresizecalls_; | 140 int onresizecalls_; |
| 141 | 141 |
| 142 std::string value_; | 142 std::string value_; |
| 143 bool verbatim_; | 143 bool verbatim_; |
| 144 int height_; | 144 int height_; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 // Test that Instant is preloaded when the omnibox is focused. | 147 // Test that Instant is preloaded when the omnibox is focused. |
| 148 IN_PROC_BROWSER_TEST_F(InstantTest, OmniboxFocusLoadsInstant) { | 148 #if defined(OS_LINUX) && defined(NDEBUG) |
| 149 // Flakily fails in Release builds - http://crbug.com/146419 |
| 150 #define MAYBE_OmniboxFocusLoadsInstant DISABLED_OmniboxFocusLoadsInstant |
| 151 #else |
| 152 #define MAYBE_OmniboxFocusLoadsInstant OmniboxFocusLoadsInstant |
| 153 #endif |
| 154 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OmniboxFocusLoadsInstant) { |
| 149 // The omnibox gets focus before the test begins. At this time, there's no | 155 // The omnibox gets focus before the test begins. At this time, there's no |
| 150 // InstantController (which is only created in SetupInstant() below), so no | 156 // InstantController (which is only created in SetupInstant() below), so no |
| 151 // preloading has happened yet. | 157 // preloading has happened yet. |
| 152 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 158 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 153 EXPECT_FALSE(instant()->GetPreviewContents()); | 159 EXPECT_FALSE(instant()->GetPreviewContents()); |
| 154 | 160 |
| 155 // Explicitly unfocus and refocus the omnibox. Since an InstantController now | 161 // Explicitly unfocus and refocus the omnibox. Since an InstantController now |
| 156 // exists, it will preload Instant. | 162 // exists, it will preload Instant. |
| 157 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 163 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 158 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 164 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 184 | 190 |
| 185 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 191 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| 186 | 192 |
| 187 // Doing a search should also use the same preloaded page. | 193 // Doing a search should also use the same preloaded page. |
| 188 SetOmniboxText("query"); | 194 SetOmniboxText("query"); |
| 189 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 195 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 190 EXPECT_TRUE(instant()->is_showing()); | 196 EXPECT_TRUE(instant()->is_showing()); |
| 191 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 197 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| 192 } | 198 } |
| 193 | 199 |
| 200 #if defined(OS_LINUX) && defined(NDEBUG) |
| 201 // Flakily fails in Release builds - http://crbug.com/146419 |
| 202 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent |
| 203 #else |
| 204 #define MAYBE_OnChangeEvent OnChangeEvent |
| 205 #endif |
| 194 // Test that the onchange event is dispatched upon typing in the omnibox. | 206 // Test that the onchange event is dispatched upon typing in the omnibox. |
| 195 IN_PROC_BROWSER_TEST_F(InstantTest, OnChangeEvent) { | 207 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnChangeEvent) { |
| 196 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 208 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 197 | 209 |
| 198 // Typing "query" into the omnibox causes the first onchange event. | 210 // Typing "query" into the omnibox causes the first onchange event. |
| 199 SetOmniboxText("query"); | 211 SetOmniboxText("query"); |
| 200 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 212 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 201 | 213 |
| 202 // The page suggested "query suggestion" is inline autocompleted into the | 214 // The page suggested "query suggestion" is inline autocompleted into the |
| 203 // omnibox, causing the second onchange event. | 215 // omnibox, causing the second onchange event. |
| 204 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 216 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
| 205 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); | 217 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); |
| 206 EXPECT_EQ(2, onchangecalls_); | 218 EXPECT_EQ(2, onchangecalls_); |
| 207 | 219 |
| 208 // Change the query and confirm that another onchange is sent. Since the new | 220 // Change the query and confirm that another onchange is sent. Since the new |
| 209 // query is not a prefix of the hardcoded "query suggestion", no inline | 221 // query is not a prefix of the hardcoded "query suggestion", no inline |
| 210 // autocompletion happens, and thus, no fourth onchange event. | 222 // autocompletion happens, and thus, no fourth onchange event. |
| 211 SetOmniboxText("search"); | 223 SetOmniboxText("search"); |
| 212 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); | 224 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); |
| 213 EXPECT_EQ(3, onchangecalls_); | 225 EXPECT_EQ(3, onchangecalls_); |
| 214 } | 226 } |
| 215 | 227 |
| 228 #if defined(OS_LINUX) && defined(NDEBUG) |
| 229 // Flakily fails in Release builds - http://crbug.com/146419 |
| 230 #define MAYBE_OnSubmitEvent DISABLED_OnSubmitEvent |
| 231 #else |
| 232 #define MAYBE_OnSubmitEvent OnSubmitEvent |
| 233 #endif |
| 216 // Test that the onsubmit event is dispatched upon pressing Enter. | 234 // Test that the onsubmit event is dispatched upon pressing Enter. |
| 217 IN_PROC_BROWSER_TEST_F(InstantTest, OnSubmitEvent) { | 235 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnSubmitEvent) { |
| 218 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 236 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 219 SetOmniboxText("search"); | 237 SetOmniboxText("search"); |
| 220 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 238 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 221 | 239 |
| 222 // Stash a reference to the preview, so we can refer to it after commit. | 240 // Stash a reference to the preview, so we can refer to it after commit. |
| 223 TabContents* preview_tab = instant()->GetPreviewContents(); | 241 TabContents* preview_tab = instant()->GetPreviewContents(); |
| 224 EXPECT_TRUE(preview_tab); | 242 EXPECT_TRUE(preview_tab); |
| 225 | 243 |
| 226 // The state of the searchbox before the commit. | 244 // The state of the searchbox before the commit. |
| 227 EXPECT_TRUE(UpdateSearchState(preview_tab)); | 245 EXPECT_TRUE(UpdateSearchState(preview_tab)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 EXPECT_TRUE(UpdateSearchState(preview_tab)); | 288 EXPECT_TRUE(UpdateSearchState(preview_tab)); |
| 271 EXPECT_EQ("search", value_); | 289 EXPECT_EQ("search", value_); |
| 272 EXPECT_TRUE(verbatim_); | 290 EXPECT_TRUE(verbatim_); |
| 273 EXPECT_EQ(1, onsubmitcalls_); | 291 EXPECT_EQ(1, onsubmitcalls_); |
| 274 } | 292 } |
| 275 | 293 |
| 276 // Test that the oncancel event is dispatched upon clicking on the preview. | 294 // Test that the oncancel event is dispatched upon clicking on the preview. |
| 277 #if defined(OS_WIN) | 295 #if defined(OS_WIN) |
| 278 // Fails frequently on the win_rel tryserver. crbug.com/145754 | 296 // Fails frequently on the win_rel tryserver. crbug.com/145754 |
| 279 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent | 297 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent |
| 298 #elif defined(OS_LINUX) && defined(NDEBUG) |
| 299 // Flakily fails in Release builds - http://crbug.com/146419 |
| 300 #define MAYBE_OnCancelEvent DISABLED_OnCancelEvent |
| 280 #else | 301 #else |
| 281 #define MAYBE_OnCancelEvent OnCancelEvent | 302 #define MAYBE_OnCancelEvent OnCancelEvent |
| 282 #endif | 303 #endif |
| 283 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnCancelEvent) { | 304 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnCancelEvent) { |
| 284 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 305 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 285 SetOmniboxText("search"); | 306 SetOmniboxText("search"); |
| 286 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 307 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 287 | 308 |
| 288 // Stash a reference to the preview, so we can refer to it after commit. | 309 // Stash a reference to the preview, so we can refer to it after commit. |
| 289 TabContents* preview_tab = instant()->GetPreviewContents(); | 310 TabContents* preview_tab = instant()->GetPreviewContents(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // Type a query into the omnibox. This should cause an onresize() event, with | 378 // Type a query into the omnibox. This should cause an onresize() event, with |
| 358 // a valid (non-zero) height. | 379 // a valid (non-zero) height. |
| 359 SetOmniboxText("search"); | 380 SetOmniboxText("search"); |
| 360 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 381 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 361 | 382 |
| 362 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); | 383 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); |
| 363 EXPECT_EQ(2, onresizecalls_); | 384 EXPECT_EQ(2, onresizecalls_); |
| 364 EXPECT_LT(0, height_); | 385 EXPECT_LT(0, height_); |
| 365 } | 386 } |
| 366 | 387 |
| 388 #if defined(OS_LINUX) && defined(NDEBUG) |
| 389 // Flakily fails in Release builds - http://crbug.com/146419 |
| 390 #define MAYBE_SuggestionIsCompletedNow DISABLED_SuggestionIsCompletedNow |
| 391 #else |
| 392 #define MAYBE_SuggestionIsCompletedNow SuggestionIsCompletedNow |
| 393 #endif |
| 367 // Test that the INSTANT_COMPLETE_NOW behavior works as expected. | 394 // Test that the INSTANT_COMPLETE_NOW behavior works as expected. |
| 368 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) { | 395 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_SuggestionIsCompletedNow) { |
| 369 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 396 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 370 instant()->OnAutocompleteGotFocus(); | 397 instant()->OnAutocompleteGotFocus(); |
| 371 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); | 398 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); |
| 372 | 399 |
| 373 // Tell the JS to request for the given behavior. | 400 // Tell the JS to request for the given behavior. |
| 374 EXPECT_TRUE(ExecuteScript("behavior = 'now'")); | 401 EXPECT_TRUE(ExecuteScript("behavior = 'now'")); |
| 375 | 402 |
| 376 SetOmniboxText("query"); | 403 SetOmniboxText("query"); |
| 377 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 404 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 378 | 405 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 486 |
| 460 // Tell the JS to use the given suggestion. | 487 // Tell the JS to use the given suggestion. |
| 461 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'query completion' } ]")); | 488 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'query completion' } ]")); |
| 462 | 489 |
| 463 SetOmniboxText("query"); | 490 SetOmniboxText("query"); |
| 464 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 491 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 465 | 492 |
| 466 EXPECT_EQ(ASCIIToUTF16("query completion"), omnibox()->GetText()); | 493 EXPECT_EQ(ASCIIToUTF16("query completion"), omnibox()->GetText()); |
| 467 } | 494 } |
| 468 | 495 |
| 496 #if defined(OS_LINUX) && defined(NDEBUG) |
| 497 // Flakily fails in Release builds - http://crbug.com/146419 |
| 498 #define MAYBE_SuggestionIsInvalidObject DISABLED_SuggestionIsInvalidObject |
| 499 #else |
| 500 #define MAYBE_SuggestionIsInvalidObject SuggestionIsInvalidObject |
| 501 #endif |
| 469 // Test that an invalid suggestion is rejected. | 502 // Test that an invalid suggestion is rejected. |
| 470 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsInvalidObject) { | 503 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_SuggestionIsInvalidObject) { |
| 471 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 504 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 472 instant()->OnAutocompleteGotFocus(); | 505 instant()->OnAutocompleteGotFocus(); |
| 473 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); | 506 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); |
| 474 | 507 |
| 475 // Tell the JS to use the given suggestion. | 508 // Tell the JS to use the given suggestion. |
| 476 EXPECT_TRUE(ExecuteScript("suggestion = { value: 'query completion' }")); | 509 EXPECT_TRUE(ExecuteScript("suggestion = { value: 'query completion' }")); |
| 477 | 510 |
| 478 SetOmniboxText("query"); | 511 SetOmniboxText("query"); |
| 479 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 512 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 480 | 513 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // Type the same search as before. The preview should show, but no onchange() | 622 // Type the same search as before. The preview should show, but no onchange() |
| 590 // is sent, since query hasn't changed. | 623 // is sent, since query hasn't changed. |
| 591 SetOmniboxText("search"); | 624 SetOmniboxText("search"); |
| 592 EXPECT_TRUE(instant()->GetPreviewContents()); | 625 EXPECT_TRUE(instant()->GetPreviewContents()); |
| 593 EXPECT_TRUE(instant()->IsCurrent()); | 626 EXPECT_TRUE(instant()->IsCurrent()); |
| 594 EXPECT_TRUE(instant()->is_showing()); | 627 EXPECT_TRUE(instant()->is_showing()); |
| 595 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); | 628 EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents())); |
| 596 EXPECT_EQ(2, onchangecalls_); | 629 EXPECT_EQ(2, onchangecalls_); |
| 597 } | 630 } |
| 598 | 631 |
| 632 #if defined(OS_LINUX) && defined(NDEBUG) |
| 633 // Flakily fails in Release builds - http://crbug.com/146419 |
| 634 #define MAYBE_DoesNotCommitURLs DISABLED_DoesNotCommitURLs |
| 635 #else |
| 636 #define MAYBE_DoesNotCommitURLs DoesNotCommitURLs |
| 637 #endif |
| 599 // Test that Instant can't be fooled into committing a URL. | 638 // Test that Instant can't be fooled into committing a URL. |
| 600 IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLs) { | 639 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_DoesNotCommitURLs) { |
| 601 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 640 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 602 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 641 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 603 | 642 |
| 604 // Type a URL. No Instant. | 643 // Type a URL. No Instant. |
| 605 SetOmniboxText("http://deadly/nadder"); | 644 SetOmniboxText("http://deadly/nadder"); |
| 606 EXPECT_FALSE(instant()->GetPreviewContents()); | 645 EXPECT_FALSE(instant()->GetPreviewContents()); |
| 607 | 646 |
| 608 // Unfocus and refocus the omnibox. | 647 // Unfocus and refocus the omnibox. |
| 609 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 648 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 610 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 649 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 EXPECT_EQ(active_tab, chrome::GetActiveTabContents(browser())); | 688 EXPECT_EQ(active_tab, chrome::GetActiveTabContents(browser())); |
| 650 EXPECT_NE(preview_tab, active_tab); | 689 EXPECT_NE(preview_tab, active_tab); |
| 651 EXPECT_EQ(ASCIIToUTF16("hideous/zippleback"), omnibox()->GetText()); | 690 EXPECT_EQ(ASCIIToUTF16("hideous/zippleback"), omnibox()->GetText()); |
| 652 | 691 |
| 653 // As before, Instant shouldn't have done anything. | 692 // As before, Instant shouldn't have done anything. |
| 654 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 693 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| 655 EXPECT_FALSE(instant()->IsCurrent()); | 694 EXPECT_FALSE(instant()->IsCurrent()); |
| 656 EXPECT_FALSE(instant()->is_showing()); | 695 EXPECT_FALSE(instant()->is_showing()); |
| 657 } | 696 } |
| 658 | 697 |
| 698 #if defined(OS_LINUX) && defined(NDEBUG) |
| 699 // Flakily fails in Release builds - http://crbug.com/146419 |
| 700 #define MAYBE_NonInstantSearchProvider DISABLED_NonInstantSearchProvider |
| 701 #else |
| 702 #define MAYBE_NonInstantSearchProvider NonInstantSearchProvider |
| 703 #endif |
| 659 // Test that a non-Instant search provider shows no previews. | 704 // Test that a non-Instant search provider shows no previews. |
| 660 IN_PROC_BROWSER_TEST_F(InstantTest, NonInstantSearchProvider) { | 705 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NonInstantSearchProvider) { |
| 661 ASSERT_NO_FATAL_FAILURE(SetupInstant("empty.html")); | 706 ASSERT_NO_FATAL_FAILURE(SetupInstant("empty.html")); |
| 662 | 707 |
| 663 // Type a query. Instant will load the search provider. | 708 // Type a query. Instant will load the search provider. |
| 664 SetOmniboxText("query"); | 709 SetOmniboxText("query"); |
| 665 EXPECT_TRUE(instant()->GetPreviewContents()); | 710 EXPECT_TRUE(instant()->GetPreviewContents()); |
| 666 | 711 |
| 667 // When the response comes back, Instant will destroy the non-Instant page. | 712 // When the response comes back, Instant will destroy the non-Instant page. |
| 668 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); | 713 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); |
| 669 EXPECT_FALSE(instant()->GetPreviewContents()); | 714 EXPECT_FALSE(instant()->GetPreviewContents()); |
| 670 } | 715 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 793 |
| 749 void KeywordQueryDone(base::RunLoop* run_loop, | 794 void KeywordQueryDone(base::RunLoop* run_loop, |
| 750 std::vector<string16>* result, | 795 std::vector<string16>* result, |
| 751 HistoryService::Handle /* handle */, | 796 HistoryService::Handle /* handle */, |
| 752 std::vector<history::KeywordSearchTermVisit>* terms) { | 797 std::vector<history::KeywordSearchTermVisit>* terms) { |
| 753 for (size_t i = 0; i < terms->size(); ++i) | 798 for (size_t i = 0; i < terms->size(); ++i) |
| 754 result->push_back((*terms)[i].term); | 799 result->push_back((*terms)[i].term); |
| 755 run_loop->Quit(); | 800 run_loop->Quit(); |
| 756 } | 801 } |
| 757 | 802 |
| 803 #if defined(OS_LINUX) && defined(NDEBUG) |
| 804 // Flakily fails in Release builds - http://crbug.com/146419 |
| 805 #define MAYBE_History DISABLED_History |
| 806 #else |
| 807 #define MAYBE_History History |
| 808 #endif |
| 758 // Test that the Instant page load is not added to history. | 809 // Test that the Instant page load is not added to history. |
| 759 IN_PROC_BROWSER_TEST_F(InstantTest, History) { | 810 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_History) { |
| 760 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 811 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 761 instant()->OnAutocompleteGotFocus(); | 812 instant()->OnAutocompleteGotFocus(); |
| 762 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); | 813 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); |
| 763 | 814 |
| 764 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( | 815 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( |
| 765 browser()->profile())->GetDefaultSearchProvider(); | 816 browser()->profile())->GetDefaultSearchProvider(); |
| 766 | 817 |
| 767 // |instant_url| is the URL Instant loads. |search_url| is the fake URL we | 818 // |instant_url| is the URL Instant loads. |search_url| is the fake URL we |
| 768 // enter into history for search terms extraction to work correctly. | 819 // enter into history for search terms extraction to work correctly. |
| 769 std::string search_url = template_url->url_ref().ReplaceSearchTerms( | 820 std::string search_url = template_url->url_ref().ReplaceSearchTerms( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 run_loop3.Run(); | 860 run_loop3.Run(); |
| 810 ASSERT_TRUE(queries.size()); | 861 ASSERT_TRUE(queries.size()); |
| 811 EXPECT_EQ(ASCIIToUTF16("search"), queries[0]); | 862 EXPECT_EQ(ASCIIToUTF16("search"), queries[0]); |
| 812 } | 863 } |
| 813 | 864 |
| 814 // On Windows, the call to NewEmptyWindow() fails the "GetBackingStore called | 865 // On Windows, the call to NewEmptyWindow() fails the "GetBackingStore called |
| 815 // while hidden" DCHECK(). It's not clear why; maybe because the active tab is | 866 // while hidden" DCHECK(). It's not clear why; maybe because the active tab is |
| 816 // in a hidden state when the Instant preview is showing, and somebody's trying | 867 // in a hidden state when the Instant preview is showing, and somebody's trying |
| 817 // to get its backing store? | 868 // to get its backing store? |
| 818 #if !defined(OS_WIN) | 869 #if !defined(OS_WIN) |
| 870 |
| 871 #if defined(OS_LINUX) && defined(NDEBUG) |
| 872 // Flakily fails in Release builds - http://crbug.com/146419 |
| 873 #define MAYBE_NewWindowDismissesInstant DISABLED_NewWindowDismissesInstant |
| 874 #else |
| 875 #define MAYBE_NewWindowDismissesInstant NewWindowDismissesInstant |
| 876 #endif |
| 819 // Test that creating a new window hides any currently showing Instant preview. | 877 // Test that creating a new window hides any currently showing Instant preview. |
| 820 IN_PROC_BROWSER_TEST_F(InstantTest, NewWindowDismissesInstant) { | 878 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NewWindowDismissesInstant) { |
| 821 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); | 879 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); |
| 822 instant()->OnAutocompleteGotFocus(); | 880 instant()->OnAutocompleteGotFocus(); |
| 823 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); | 881 WaitFor(chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED); |
| 824 | 882 |
| 825 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 883 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 826 SetOmniboxText("search"); | 884 SetOmniboxText("search"); |
| 827 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); | 885 WaitFor(chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN); |
| 828 EXPECT_TRUE(instant()->GetPreviewContents()); | 886 EXPECT_TRUE(instant()->GetPreviewContents()); |
| 829 EXPECT_TRUE(instant()->IsCurrent()); | 887 EXPECT_TRUE(instant()->IsCurrent()); |
| 830 EXPECT_TRUE(instant()->is_showing()); | 888 EXPECT_TRUE(instant()->is_showing()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 // Refresh the loader, the preview contents should remain the same. | 921 // Refresh the loader, the preview contents should remain the same. |
| 864 instant()->OnStaleLoader(); | 922 instant()->OnStaleLoader(); |
| 865 EXPECT_TRUE(instant()->is_showing()); | 923 EXPECT_TRUE(instant()->is_showing()); |
| 866 | 924 |
| 867 instant()->stale_loader_timer_.Stop(); | 925 instant()->stale_loader_timer_.Stop(); |
| 868 // The refresh should happen once the omnibox loses focus. | 926 // The refresh should happen once the omnibox loses focus. |
| 869 EXPECT_TRUE(instant()->loader()->supports_instant()); | 927 EXPECT_TRUE(instant()->loader()->supports_instant()); |
| 870 instant()->OnAutocompleteLostFocus(NULL); | 928 instant()->OnAutocompleteLostFocus(NULL); |
| 871 EXPECT_FALSE(instant()->loader()->supports_instant()); | 929 EXPECT_FALSE(instant()->loader()->supports_instant()); |
| 872 } | 930 } |
| OLD | NEW |