diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-07 19:36:17 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-07 19:36:17 +0000 |
commit | 0385fc680515fe21df6fc1cbb091e7a041230368 (patch) | |
tree | 3b62d2f3ee8e5af5870eededc72482996b92db98 | |
parent | 075fb0ffcb8de17e3fc48a27f19d3f7416e10ce4 (diff) | |
download | chromium_src-0385fc680515fe21df6fc1cbb091e7a041230368.zip chromium_src-0385fc680515fe21df6fc1cbb091e7a041230368.tar.gz chromium_src-0385fc680515fe21df6fc1cbb091e7a041230368.tar.bz2 |
Changes SearchProvider to set the description of the first consecutive
match sharing the same template url. For example, if the results were
'A B C D' with 'A' and 'B' sharing the same provider and 'C' and 'D'
sharing the same provider, then 'A' and 'C' would get descriptions.
As part of this I'm always setting AutocompleteMatch::template_url
(previously we only set it for keywords).
BUG=88322
TEST=see bug, also covered by unit tests.
R=pkasting@chromium.org
Review URL: http://codereview.chromium.org/7321001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91741 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.cc | 11 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.h | 10 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit.cc | 19 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_match.h | 4 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_model.cc | 28 | ||||
-rw-r--r-- | chrome/browser/autocomplete/search_provider.cc | 74 | ||||
-rw-r--r-- | chrome/browser/autocomplete/search_provider.h | 8 | ||||
-rw-r--r-- | chrome/browser/autocomplete/search_provider_unittest.cc | 58 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.cc | 15 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.h | 4 | ||||
-rw-r--r-- | chrome/browser/search_engines/template_url_service.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/omnibox/omnibox_view_win.cc | 2 | ||||
-rw-r--r-- | chrome/test/functional/omnibox.py | 4 |
13 files changed, 146 insertions, 95 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 40ad6d2..ab72ec2 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -506,6 +506,9 @@ void AutocompleteProvider::Stop() { void AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) { } +void AutocompleteProvider::PostProcessResult(AutocompleteResult* result) { +} + AutocompleteProvider::~AutocompleteProvider() { Stop(); } @@ -949,6 +952,14 @@ void AutocompleteController::UpdateResult(bool is_synchronous_pass) { result_.CopyOldMatches(input_, last_result); } + size_t start_size = result_.size(); + for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); + ++i) + (*i)->PostProcessResult(&result_); + // Providers should not alter the number of matches, otherwise it's very + // likely the matches are no longer sorted. + DCHECK_EQ(start_size, result_.size()); + bool notify_default_match = is_synchronous_pass; if (!is_synchronous_pass) { const bool last_default_was_valid = diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h index eaf2318..ee73d69 100644 --- a/chrome/browser/autocomplete/autocomplete.h +++ b/chrome/browser/autocomplete/autocomplete.h @@ -402,6 +402,16 @@ class AutocompleteProvider // NOTE: Remember to call OnProviderUpdate() if matches_ is updated. virtual void DeleteMatch(const AutocompleteMatch& match); + // Invoked after combining the results from all providers (including sorting, + // culling and all that) but before the AutocompleteController's delegate is + // notified. This is exposed to allow providers to alter the descriptions of + // matches based on position in the final result set. Providers should not use + // this to add new matches. + virtual void PostProcessResult(AutocompleteResult* result); + +#ifdef UNIT_TEST + void set_listener(ACProviderListener* listener) { listener_ = listener; } +#endif // A suggested upper bound for how many matches a provider should return. // TODO(pkasting): http://b/1111299 , http://b/933133 This should go away once // we have good relevance heuristics; the controller should handle all diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 048bea2..5d27978 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -469,21 +469,14 @@ void AutocompleteEditModel::AcceptInput(WindowOpenDisposition disposition, match.transition = PageTransition::LINK; } - if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || - match.type == AutocompleteMatch::SEARCH_HISTORY || - match.type == AutocompleteMatch::SEARCH_SUGGEST) { - const TemplateURL* default_provider = - TemplateURLServiceFactory::GetForProfile(profile_)-> - GetDefaultSearchProvider(); - if (default_provider && default_provider->url() && - default_provider->url()->HasGoogleBaseURLs()) { - GoogleURLTracker::GoogleURLSearchCommitted(); + if (match.template_url && match.template_url->url() && + match.template_url->url()->HasGoogleBaseURLs()) { + GoogleURLTracker::GoogleURLSearchCommitted(); #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) - // TODO(pastarmovj): Remove these metrics once we have proven that (close - // to) none searches that should have RLZ are sent out without one. - default_provider->url()->CollectRLZMetrics(); + // TODO(pastarmovj): Remove these metrics once we have proven that (close + // to) none searches that should have RLZ are sent out without one. + match.template_url->url()->CollectRLZMetrics(); #endif - } } view_->OpenMatch(match, disposition, alternate_nav_url, diff --git a/chrome/browser/autocomplete/autocomplete_match.h b/chrome/browser/autocomplete/autocomplete_match.h index 81ac840..fbf8355 100644 --- a/chrome/browser/autocomplete/autocomplete_match.h +++ b/chrome/browser/autocomplete/autocomplete_match.h @@ -177,8 +177,8 @@ struct AutocompleteMatch { // Type of this match. Type type; - // If this match corresponds to a keyword, this is the TemplateURL the - // keyword was obtained from. + // Indicates the TemplateURL the match originated from. This is set for + // keywords as well as matches for the default search provider. const TemplateURL* template_url; // True if the user has starred the destination URL. diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc index ea8492f..459560f 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_model.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc @@ -131,10 +131,30 @@ void AutocompletePopupModel::ResetToDefaultMatch() { bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match, string16* keyword) const { - // If the current match is a keyword, return that as the selected keyword. - if (TemplateURL::SupportsReplacement(match.template_url)) { - keyword->assign(match.template_url->keyword()); - return false; + // Assume we have no keyword until we find otherwise. + keyword->clear(); + + if (match.template_url) { + TemplateURLService* url_service = + TemplateURLServiceFactory::GetForProfile(profile_); + if (!url_service) + return false; + + // Only show the keyword for the default provider if the user typed in + // the keyword and it isn't SEARCH_WHAT_YOU_TYPED. + const TemplateURL* default_url = url_service->GetDefaultSearchProvider(); + if (default_url && (default_url->id() == match.template_url->id())) { + if (StartsWith(autocomplete_controller()->input().text(), + default_url->keyword(), false) && + (match.type != AutocompleteMatch::SEARCH_WHAT_YOU_TYPED)) { + keyword->assign(match.template_url->keyword()); + return false; + } + } else if (TemplateURL::SupportsReplacement(match.template_url)) { + // The current match is a keyword, return that as the selected keyword. + keyword->assign(match.template_url->keyword()); + return false; + } } // See if the current match's fill_into_edit corresponds to a keyword. diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 1fbddb6..706a091 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -91,16 +91,6 @@ void SearchProvider::FinalizeInstantQuery(const string16& input_text, // destination_url for comparison as it varies depending upon the index passed // to TemplateURL::ReplaceSearchTerms. for (ACMatches::iterator i = matches_.begin(); i != matches_.end();) { - // Reset the description/description_class of all searches. We'll set the - // description of the new first match in the call to - // UpdateFirstSearchMatchDescription() below. - if ((i->type == AutocompleteMatch::SEARCH_HISTORY) || - (i->type == AutocompleteMatch::SEARCH_SUGGEST) || - (i->type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED)) { - i->description.clear(); - i->description_class.clear(); - } - if (((i->type == AutocompleteMatch::SEARCH_HISTORY) || (i->type == AutocompleteMatch::SEARCH_SUGGEST)) && (i->fill_into_edit == text)) { @@ -123,10 +113,6 @@ void SearchProvider::FinalizeInstantQuery(const string16& input_text, input_.prevent_inline_autocomplete(), &match_map); DCHECK_EQ(1u, match_map.size()); matches_.push_back(match_map.begin()->second); - // Sort the results so that UpdateFirstSearchDescription does the right thing. - std::sort(matches_.begin(), matches_.end(), &AutocompleteMatch::MoreRelevant); - - UpdateFirstSearchMatchDescription(); listener_->OnProviderUpdate(true); } @@ -187,8 +173,8 @@ void SearchProvider::Start(const AutocompleteInput& input, match.contents.assign(l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE)); match.contents_class.push_back( ACMatchClassification(0, ACMatchClassification::NONE)); + match.template_url = &providers_.default_provider(); matches_.push_back(match); - UpdateFirstSearchMatchDescription(); } Stop(); return; @@ -229,6 +215,33 @@ void SearchProvider::Stop() { default_provider_suggest_text_.clear(); } +void SearchProvider::PostProcessResult(AutocompleteResult* result) { + // For each group of contiguous matches from the same TemplateURL, show the + // provider name as a description on the first match in the group. + const TemplateURL* last_template_url = NULL; + for (AutocompleteResult::iterator i = result->begin(); i != result->end(); + ++i) { + if (i->provider == this && + (i->type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || + i->type == AutocompleteMatch::SEARCH_HISTORY || + i->type == AutocompleteMatch::SEARCH_SUGGEST)) { + i->description.clear(); + i->description_class.clear(); + DCHECK(i->template_url); // We should always set a template_url + if (last_template_url != i->template_url) { + i->description = l10n_util::GetStringFUTF16( + IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, + i->template_url->AdjustedShortNameForLocaleDirection()); + i->description_class.push_back( + ACMatchClassification(0, ACMatchClassification::DIM)); + } + last_template_url = i->template_url; + } else { + last_template_url = NULL; + } + } +} + void SearchProvider::OnURLFetchComplete(const URLFetcher* source, const GURL& url, const net::URLRequestStatus& status, @@ -577,8 +590,6 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() { if (matches_.size() > max_total_matches) matches_.erase(matches_.begin() + max_total_matches, matches_.end()); - UpdateFirstSearchMatchDescription(); - UpdateStarredStateOfMatches(); UpdateDone(); @@ -758,6 +769,7 @@ void SearchProvider::AddMatchToMap(const string16& query_string, std::vector<size_t> content_param_offsets; const TemplateURL& provider = is_keyword ? providers_.keyword_provider() : providers_.default_provider(); + match.template_url = &provider; match.contents.assign(query_string); // We do intra-string highlighting for suggestions - the suggested segment // will be highlighted, e.g. for input_text = "you" the suggestion may be @@ -809,7 +821,6 @@ void SearchProvider::AddMatchToMap(const string16& query_string, if (is_keyword) { match.fill_into_edit.append( providers_.keyword_provider().keyword() + char16(' ')); - match.template_url = &providers_.keyword_provider(); } match.fill_into_edit.append(query_string); // Not all suggestions start with the original input. @@ -859,6 +870,8 @@ AutocompleteMatch SearchProvider::NavigationToMatch( match.destination_url = navigation.url; match.contents = StringForURLDisplay(navigation.url, true, !HasHTTPScheme(input_text)); + match.template_url = is_keyword ? &providers_.keyword_provider() : + &providers_.default_provider(); AutocompleteMatch::ClassifyMatchInString(input_text, match.contents, ACMatchClassification::URL, &match.contents_class); @@ -888,28 +901,3 @@ void SearchProvider::UpdateDone() { done_ = ((suggest_results_pending_ == 0) && (instant_finalized_ || !InstantController::IsEnabled(profile_))); } - -void SearchProvider::UpdateFirstSearchMatchDescription() { - if (!providers_.valid_default_provider() || matches_.empty()) - return; - - for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) { - AutocompleteMatch& match = *i; - switch (match.type) { - case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED: - case AutocompleteMatch::SEARCH_HISTORY: - case AutocompleteMatch::SEARCH_SUGGEST: - match.description.assign(l10n_util::GetStringFUTF16( - IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION, - providers_.default_provider(). - AdjustedShortNameForLocaleDirection())); - match.description_class.push_back( - ACMatchClassification(0, ACMatchClassification::DIM)); - // Only the first search match gets a description. - return; - - default: - break; - } - } -} diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h index bf18bd0..e0a747a 100644 --- a/chrome/browser/autocomplete/search_provider.h +++ b/chrome/browser/autocomplete/search_provider.h @@ -64,8 +64,9 @@ class SearchProvider : public AutocompleteProvider, // AutocompleteProvider virtual void Start(const AutocompleteInput& input, - bool minimal_changes); - virtual void Stop(); + bool minimal_changes) OVERRIDE; + virtual void Stop() OVERRIDE; + virtual void PostProcessResult(AutocompleteResult* result) OVERRIDE; // URLFetcher::Delegate virtual void OnURLFetchComplete(const URLFetcher* source, @@ -270,9 +271,6 @@ class SearchProvider : public AutocompleteProvider, // Updates the value of |done_| from the internal state. void UpdateDone(); - // Updates the description/description_class of the first search match. - void UpdateFirstSearchMatchDescription(); - // Should we query for suggest results immediately? This is normally false, // but may be set to true during testing. static bool query_suggest_immediately_; diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 4a1263e..dfeaaa4 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/autocomplete/search_provider.h" + #include "base/string_util.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "build/build_config.h" +#include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/autocomplete/autocomplete_match.h" -#include "chrome/browser/autocomplete/search_provider.h" #include "chrome/browser/history/history.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/search_engines/template_url.h" @@ -108,10 +110,13 @@ void SearchProviderTest::SetUp() { TemplateURLService* turl_model = TemplateURLServiceFactory::GetForProfile(&profile_); + turl_model->Load(); + // Reset the default TemplateURL. default_t_url_ = new TemplateURL(); default_t_url_->SetURL("http://defaultturl/{searchTerms}", 0, 0); default_t_url_->SetSuggestionsURL("http://defaultturl2/{searchTerms}", 0, 0); + default_t_url_->set_short_name(ASCIIToUTF16("t")); turl_model->Add(default_t_url_); turl_model->SetDefaultSearchProvider(default_t_url_); TemplateURLID default_provider_id = default_t_url_->id(); @@ -131,6 +136,7 @@ void SearchProviderTest::SetUp() { // Create another TemplateURL. keyword_t_url_ = new TemplateURL(); keyword_t_url_->set_keyword(ASCIIToUTF16("k")); + keyword_t_url_->set_short_name(ASCIIToUTF16("k")); keyword_t_url_->SetURL("http://keyword/{searchTerms}", 0, 0); keyword_t_url_->SetSuggestionsURL("http://suggest_keyword/{searchTerms}", 0, 0); @@ -249,8 +255,8 @@ TEST_F(SearchProviderTest, QueryDefaultProvider) { // term term1. AutocompleteMatch term1_match = FindMatchWithDestination(term1_url_); EXPECT_TRUE(!term1_match.destination_url.is_empty()); - // Term1 should have a description. - EXPECT_FALSE(term1_match.description.empty()); + // Term1 should not have a description, it's set later. + EXPECT_TRUE(term1_match.description.empty()); GURL what_you_typed_url = GURL(default_t_url_->url()->ReplaceSearchTerms( *default_t_url_, term, 0, string16())); @@ -378,8 +384,8 @@ TEST_F(SearchProviderTest, FinalizeInstantQuery) { AutocompleteMatch instant_match = FindMatchWithDestination(instant_url); EXPECT_TRUE(!instant_match.destination_url.is_empty()); - // And the 'foobar' match should have a description. - EXPECT_FALSE(instant_match.description.empty()); + // And the 'foobar' match should not have a description, it'll be set later. + EXPECT_TRUE(instant_match.description.empty()); // Make sure the what you typed match has no description. GURL what_you_typed_url = GURL(default_t_url_->url()->ReplaceSearchTerms( @@ -425,8 +431,8 @@ TEST_F(SearchProviderTest, RememberInstantQuery) { instant_match = FindMatchWithDestination(instant_url); EXPECT_FALSE(instant_match.destination_url.is_empty()); - // And the 'foobar' match should have a description. - EXPECT_FALSE(instant_match.description.empty()); + // And the 'foobar' match should not have a description, it'll be set later. + EXPECT_TRUE(instant_match.description.empty()); } // Make sure that if trailing whitespace is added to the text supplied to @@ -533,3 +539,41 @@ TEST_F(SearchProviderTest, AutocompletePreviousSearchOnSpace) { // And the offset should be at 4. EXPECT_EQ(4u, term_match.inline_autocomplete_offset); } + +// Verifies the SearchProvider sets descriptions for results correctly. +TEST_F(SearchProviderTest, PostProcessResults) { + // Add an entry that corresponds to a keyword search with 'term2'. + string16 term(ASCIIToUTF16("term2")); + HistoryService* history = + profile_.GetHistoryService(Profile::EXPLICIT_ACCESS); + GURL term_url(keyword_t_url_->url()->ReplaceSearchTerms( + *keyword_t_url_, term, 0, string16())); + history->AddPageWithDetails(term_url, string16(), 1, 1, + base::Time::Now(), false, + history::SOURCE_BROWSED); + history->SetKeywordSearchTermsForURL(term_url, keyword_t_url_->id(), term); + + profile_.BlockUntilHistoryProcessesPendingRequests(); + + ACProviders providers; + SearchProvider* provider = provider_.release(); + providers.push_back(provider); + AutocompleteController controller(providers); + provider->set_listener(&controller); + controller.Start(ASCIIToUTF16("k t"), string16(), false, false, true, + AutocompleteInput::ALL_MATCHES); + const AutocompleteResult& result = controller.result(); + + // There should be two matches, one for the keyword one for what you typed. + ASSERT_EQ(2u, result.size()); + + EXPECT_TRUE(result.match_at(0).template_url != NULL); + EXPECT_TRUE(result.match_at(1).template_url != NULL); + EXPECT_NE(result.match_at(0).template_url, + result.match_at(1).template_url); + + EXPECT_FALSE(result.match_at(0).description.empty()); + EXPECT_FALSE(result.match_at(1).description.empty()); + EXPECT_NE(result.match_at(0).description, + result.match_at(1).description); +} diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 61cedf0..c7a6653 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -678,7 +678,7 @@ void InstantController::UpdateLoader(const TemplateURL* template_url, InstantController::PreviewCondition InstantController::GetPreviewConditionFor( const AutocompleteMatch& match, const TemplateURL** template_url) { - const TemplateURL* t_url = GetTemplateURL(match); + const TemplateURL* t_url = match.template_url; if (t_url) { if (!t_url->id() || !t_url->instant_url() || @@ -738,16 +738,3 @@ void InstantController::ScheduleDestroy(InstantLoader* loader) { void InstantController::DestroyLoaders() { loaders_to_destroy_.reset(); } - -const TemplateURL* InstantController::GetTemplateURL( - const AutocompleteMatch& match) { - const TemplateURL* template_url = match.template_url; - if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || - match.type == AutocompleteMatch::SEARCH_HISTORY || - match.type == AutocompleteMatch::SEARCH_SUGGEST) { - TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( - tab_contents_->profile()); - template_url = model ? model->GetDefaultSearchProvider() : NULL; - } - return template_url; -} diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index 8556e85..4d12adb 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -263,10 +263,6 @@ class InstantController : public InstantLoaderDelegate { // Destroys all loaders scheduled for destruction in |ScheduleForDestroy|. void DestroyLoaders(); - // Returns the TemplateURL to use for the specified AutocompleteMatch, or - // NULL if there is no TemplateURL for |match|. - const TemplateURL* GetTemplateURL(const AutocompleteMatch& match); - InstantDelegate* delegate_; // The TabContents last passed to |Update|. diff --git a/chrome/browser/search_engines/template_url_service.h b/chrome/browser/search_engines/template_url_service.h index d029d86..10eeb10 100644 --- a/chrome/browser/search_engines/template_url_service.h +++ b/chrome/browser/search_engines/template_url_service.h @@ -203,6 +203,10 @@ class TemplateURLService : public WebDataServiceConsumer, // OnTemplateURLServiceChanged. void Load(); +#if defined(UNIT_TEST) + void set_loaded(bool value) { loaded_ = value; } +#endif + // Whether or not the keywords have been loaded. bool loaded() { return loaded_; } diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc index 339d54a..da20ab8 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc @@ -28,8 +28,6 @@ #include "chrome/browser/command_updater.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/search_engines/template_url.h" -#include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/user_metrics.h" diff --git a/chrome/test/functional/omnibox.py b/chrome/test/functional/omnibox.py index 02dc111..7e9105f 100644 --- a/chrome/test/functional/omnibox.py +++ b/chrome/test/functional/omnibox.py @@ -126,7 +126,9 @@ class OmniboxTest(pyauto.PyUITest): matches_description = test_utils.GetOmniboxMatchesFor(self, search_text, attr_dict={'description': verify_str}) self.assertTrue(matches_description) - self.assertEqual(1, len(matches_description)) + # There should be a least one entry with the description Google. Suggest + # results may end up having 'Google Search' in them, so use >=. + self.assertTrue(len(matches_description) >= 1) item = matches_description[0] self.assertTrue(re.search(url_re, item['destination_url'])) self.assertEqual('search-what-you-typed', item['type']) |