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

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

Issue 481693004: Omnibox: Prevent Asynchronous Suggestions from Changing Default Match (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 3 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_base.h" 8 #include "base/metrics/histogram_base.h"
9 #include "base/metrics/histogram_samples.h" 9 #include "base/metrics/histogram_samples.h"
10 #include "base/metrics/statistics_recorder.h" 10 #include "base/metrics/statistics_recorder.h"
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 827
828 // Navigate to a search results page. 828 // Navigate to a search results page.
829 content::WindowedNotificationObserver observer( 829 content::WindowedNotificationObserver observer(
830 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 830 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
831 content::NotificationService::AllSources()); 831 content::NotificationService::AllSources());
832 SetOmniboxText("flowers"); 832 SetOmniboxText("flowers");
833 PressEnterAndWaitForNavigation(); 833 PressEnterAndWaitForNavigation();
834 observer.Wait(); 834 observer.Wait();
835 835
836 // Set the fake response for suggest request. Response has prefetch details. 836 // Set the fake response for suggest request. Response has prefetch details.
837 // Ensure that the page received the prefetch query. 837 // Ensure that the page received the suggest response, then add another
838 // keystroke to allow the asynchronously-received inline autocomplete
839 // suggestion to actually be inlined (which in turn triggers it to prefetch).
838 fake_factory()->SetFakeResponse( 840 fake_factory()->SetFakeResponse(
839 instant_url().Resolve("#q=pupp"), 841 instant_url().Resolve("#q=pup"),
840 "[\"pupp\",[\"puppy\", \"puppies\"],[],[]," 842 "[\"pup\",[\"puppy\", \"puppies\"],[],[],"
841 "{\"google:clientdata\":{\"phi\": 0}," 843 "{\"google:clientdata\":{\"phi\": 0},"
842 "\"google:suggesttype\":[\"QUERY\", \"QUERY\"]," 844 "\"google:suggesttype\":[\"QUERY\", \"QUERY\"],"
843 "\"google:suggestrelevance\":[1400, 9]}]", 845 "\"google:suggestrelevance\":[1400, 9]}]",
844 net::HTTP_OK, 846 net::HTTP_OK,
845 net::URLRequestStatus::SUCCESS); 847 net::URLRequestStatus::SUCCESS);
846 848
847 SetOmniboxText("pupp"); 849 SetOmniboxText("pup");
848 while (!omnibox()->model()->autocomplete_controller()->done()) { 850 while (!omnibox()->model()->autocomplete_controller()->done()) {
849 content::WindowedNotificationObserver ready_observer( 851 content::WindowedNotificationObserver ready_observer(
850 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 852 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
851 content::Source<AutocompleteController>( 853 content::Source<AutocompleteController>(
852 omnibox()->model()->autocomplete_controller())); 854 omnibox()->model()->autocomplete_controller()));
853 ready_observer.Wait(); 855 ready_observer.Wait();
854 } 856 }
857 SetOmniboxText("pupp");
855 858
856 ASSERT_EQ(3, CountSearchProviderSuggestions()); 859 ASSERT_EQ(3, CountSearchProviderSuggestions());
857 content::WebContents* active_tab = 860 content::WebContents* active_tab =
858 browser()->tab_strip_model()->GetActiveWebContents(); 861 browser()->tab_strip_model()->GetActiveWebContents();
859 ASSERT_TRUE(UpdateSearchState(active_tab)); 862 ASSERT_TRUE(UpdateSearchState(active_tab));
860 ASSERT_TRUE(SearchProvider::ShouldPrefetch(*( 863 ASSERT_TRUE(SearchProvider::ShouldPrefetch(*(
861 omnibox()->model()->result().default_match()))); 864 omnibox()->model()->result().default_match())));
862 ASSERT_EQ("puppy", prefetch_query_value_); 865 ASSERT_EQ("puppy", prefetch_query_value_);
863 } 866 }
864 867
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 stream << "link.href = \"" << result_url.spec() << "\";"; 973 stream << "link.href = \"" << result_url.spec() << "\";";
971 stream << "document.body.appendChild(link);"; 974 stream << "document.body.appendChild(link);";
972 stream << "link.click();"; 975 stream << "link.click();";
973 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); 976 EXPECT_TRUE(content::ExecuteScript(contents, stream.str()));
974 977
975 content::WaitForLoadStop(contents); 978 content::WaitForLoadStop(contents);
976 std::string expected_title = 979 std::string expected_title =
977 "Referrer is " + instant_url().GetWithEmptyPath().spec(); 980 "Referrer is " + instant_url().GetWithEmptyPath().spec();
978 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); 981 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle());
979 } 982 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | components/omnibox/base_search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698