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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_provider_unittest.cc

Issue 11198074: Initial implementation of dedupping search provider's URLs. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add a missing include. Created 8 years, 1 month 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 (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 "chrome/browser/autocomplete/autocomplete_provider.h" 5 #include "chrome/browser/autocomplete/autocomplete_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 match.contents = match.fill_into_edit; 130 match.contents = match.fill_into_edit;
131 match.contents_class.push_back( 131 match.contents_class.push_back(
132 ACMatchClassification(0, ACMatchClassification::NONE)); 132 ACMatchClassification(0, ACMatchClassification::NONE));
133 match.description = match.fill_into_edit; 133 match.description = match.fill_into_edit;
134 match.description_class.push_back( 134 match.description_class.push_back(
135 ACMatchClassification(0, ACMatchClassification::NONE)); 135 ACMatchClassification(0, ACMatchClassification::NONE));
136 match.search_terms_args.reset( 136 match.search_terms_args.reset(
137 new TemplateURLRef::SearchTermsArgs(search_terms_args)); 137 new TemplateURLRef::SearchTermsArgs(search_terms_args));
138 if (!match_keyword_.empty()) { 138 if (!match_keyword_.empty()) {
139 match.keyword = match_keyword_; 139 match.keyword = match_keyword_;
140 ASSERT_TRUE(match.GetTemplateURL(profile_) != NULL); 140 ASSERT_TRUE(match.GetTemplateURL(profile_, false) != NULL);
141 } 141 }
142 142
143 matches_.push_back(match); 143 matches_.push_back(match);
144 } 144 }
145 } 145 }
146 146
147 class AutocompleteProviderTest : public testing::Test, 147 class AutocompleteProviderTest : public testing::Test,
148 public content::NotificationObserver { 148 public content::NotificationObserver {
149 protected: 149 protected:
150 struct KeywordTestData { 150 struct KeywordTestData {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // content::NotificationObserver 192 // content::NotificationObserver
193 virtual void Observe(int type, 193 virtual void Observe(int type,
194 const content::NotificationSource& source, 194 const content::NotificationSource& source,
195 const content::NotificationDetails& details); 195 const content::NotificationDetails& details);
196 196
197 MessageLoopForUI message_loop_; 197 MessageLoopForUI message_loop_;
198 content::NotificationRegistrar registrar_; 198 content::NotificationRegistrar registrar_;
199 TestingProfile profile_; 199 TestingProfile profile_;
200 }; 200 };
201 201
202 void AutocompleteProviderTest:: RegisterTemplateURL( 202 void AutocompleteProviderTest::RegisterTemplateURL(
203 const string16 keyword, 203 const string16 keyword,
204 const std::string& template_url) { 204 const std::string& template_url) {
205 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 205 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
206 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); 206 &profile_, &TemplateURLServiceFactory::BuildInstanceFor);
207 TemplateURLData data; 207 TemplateURLData data;
208 data.SetURL(template_url); 208 data.SetURL(template_url);
209 data.SetKeyword(keyword); 209 data.SetKeyword(keyword);
210 TemplateURL* default_t_url = new TemplateURL(&profile_, data); 210 TemplateURL* default_t_url = new TemplateURL(&profile_, data);
211 TemplateURLService* turl_model = 211 TemplateURLService* turl_model =
212 TemplateURLServiceFactory::GetForProfile(&profile_); 212 TemplateURLServiceFactory::GetForProfile(&profile_);
213 turl_model->Add(default_t_url); 213 turl_model->Add(default_t_url);
214 turl_model->SetDefaultSearchProvider(default_t_url); 214 turl_model->SetDefaultSearchProvider(default_t_url);
215 turl_model->Load();
215 TemplateURLID default_provider_id = default_t_url->id(); 216 TemplateURLID default_provider_id = default_t_url->id();
216 ASSERT_NE(0, default_provider_id); 217 ASSERT_NE(0, default_provider_id);
217 } 218 }
218 219
219 void AutocompleteProviderTest::ResetControllerWithTestProviders( 220 void AutocompleteProviderTest::ResetControllerWithTestProviders(
220 bool same_destinations, 221 bool same_destinations,
221 TestProvider** provider1_ptr, 222 TestProvider** provider1_ptr,
222 TestProvider** provider2_ptr) { 223 TestProvider** provider2_ptr) {
223 // TODO: Move it outside this method, after refactoring the existing 224 // TODO: Move it outside this method, after refactoring the existing
224 // unit tests. Specifically: 225 // unit tests. Specifically:
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, 542 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" },
542 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, 543 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" },
543 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, 544 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" },
544 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, 545 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" },
545 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, 546 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" },
546 }; 547 };
547 SCOPED_TRACE("Multiple matches"); 548 SCOPED_TRACE("Multiple matches");
548 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); 549 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
549 } 550 }
550 } 551 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_match.cc ('k') | chrome/browser/autocomplete/autocomplete_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698