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

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

Issue 10909130: autocomplete: Add AutocompleteProvider::Type enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add !! for windows Created 8 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 (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 27 matching lines...) Expand all
38 const char kTestTemplateURLKeyword[] = "t"; 38 const char kTestTemplateURLKeyword[] = "t";
39 } 39 }
40 40
41 // Autocomplete provider that provides known results. Note that this is 41 // Autocomplete provider that provides known results. Note that this is
42 // refcounted so that it can also be a task on the message loop. 42 // refcounted so that it can also be a task on the message loop.
43 class TestProvider : public AutocompleteProvider { 43 class TestProvider : public AutocompleteProvider {
44 public: 44 public:
45 TestProvider(int relevance, const string16& prefix, 45 TestProvider(int relevance, const string16& prefix,
46 Profile* profile, 46 Profile* profile,
47 const string16 match_keyword) 47 const string16 match_keyword)
48 : AutocompleteProvider(NULL, profile, ""), 48 : AutocompleteProvider(NULL, profile, AutocompleteProvider::TYPE_SEARCH),
49 relevance_(relevance), 49 relevance_(relevance),
50 prefix_(prefix), 50 prefix_(prefix),
51 match_keyword_(match_keyword) { 51 match_keyword_(match_keyword) {
52 } 52 }
53 53
54 virtual void Start(const AutocompleteInput& input, 54 virtual void Start(const AutocompleteInput& input,
55 bool minimal_changes); 55 bool minimal_changes);
56 56
57 void set_listener(AutocompleteProviderListener* listener) { 57 void set_listener(AutocompleteProviderListener* listener) {
58 listener_ = listener; 58 listener_ = listener;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 struct AssistedQueryStatsTestData { 156 struct AssistedQueryStatsTestData {
157 const AutocompleteMatch::Type match_type; 157 const AutocompleteMatch::Type match_type;
158 const std::string expected_aqs; 158 const std::string expected_aqs;
159 }; 159 };
160 160
161 protected: 161 protected:
162 // Registers a test TemplateURL under the given keyword. 162 // Registers a test TemplateURL under the given keyword.
163 void RegisterTemplateURL(const string16 keyword, 163 void RegisterTemplateURL(const string16 keyword,
164 const std::string& template_url); 164 const std::string& template_url);
165 165
166 void ResetControllerWithTestProviders(bool same_destinations); 166 // Resets |controller_| with two TestProviders. |provider1_ptr| and
167 // |provider2_ptr| are updated to point to the new providers if non-NULL.
168 void ResetControllerWithTestProviders(bool same_destinations,
169 TestProvider** provider1_ptr,
170 TestProvider** provider2_ptr);
167 171
168 // Runs a query on the input "a", and makes sure both providers' input is 172 // Runs a query on the input "a", and makes sure both providers' input is
169 // properly collected. 173 // properly collected.
170 void RunTest(); 174 void RunTest();
171 175
172 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); 176 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size);
173 177
174 void RunAssistedQueryStatsTest( 178 void RunAssistedQueryStatsTest(
175 const AssistedQueryStatsTestData* aqs_test_data, 179 const AssistedQueryStatsTestData* aqs_test_data,
176 size_t size); 180 size_t size);
177 181
178 void RunQuery(const string16 query); 182 void RunQuery(const string16 query);
179 183
180 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); 184 void ResetControllerWithKeywordAndSearchProviders();
181 void ResetControllerWithKeywordProvider(); 185 void ResetControllerWithKeywordProvider();
182 void RunExactKeymatchTest(bool allow_exact_keyword_match); 186 void RunExactKeymatchTest(bool allow_exact_keyword_match);
183 187
184 // These providers are owned by the controller once it's created.
185 ACProviders providers_;
186
187 AutocompleteResult result_; 188 AutocompleteResult result_;
188 scoped_ptr<AutocompleteController> controller_; 189 scoped_ptr<AutocompleteController> controller_;
189 190
190 private: 191 private:
191 // content::NotificationObserver 192 // content::NotificationObserver
192 virtual void Observe(int type, 193 virtual void Observe(int type,
193 const content::NotificationSource& source, 194 const content::NotificationSource& source,
194 const content::NotificationDetails& details); 195 const content::NotificationDetails& details);
195 196
196 MessageLoopForUI message_loop_; 197 MessageLoopForUI message_loop_;
(...skipping 12 matching lines...) Expand all
209 TemplateURL* default_t_url = new TemplateURL(&profile_, data); 210 TemplateURL* default_t_url = new TemplateURL(&profile_, data);
210 TemplateURLService* turl_model = 211 TemplateURLService* turl_model =
211 TemplateURLServiceFactory::GetForProfile(&profile_); 212 TemplateURLServiceFactory::GetForProfile(&profile_);
212 turl_model->Add(default_t_url); 213 turl_model->Add(default_t_url);
213 turl_model->SetDefaultSearchProvider(default_t_url); 214 turl_model->SetDefaultSearchProvider(default_t_url);
214 TemplateURLID default_provider_id = default_t_url->id(); 215 TemplateURLID default_provider_id = default_t_url->id();
215 ASSERT_NE(0, default_provider_id); 216 ASSERT_NE(0, default_provider_id);
216 } 217 }
217 218
218 void AutocompleteProviderTest::ResetControllerWithTestProviders( 219 void AutocompleteProviderTest::ResetControllerWithTestProviders(
219 bool same_destinations) { 220 bool same_destinations,
220 // Forget about any existing providers. The controller owns them and will 221 TestProvider** provider1_ptr,
221 // Release() them below, when we delete it during the call to reset(). 222 TestProvider** provider2_ptr) {
222 providers_.clear();
223
224 // TODO: Move it outside this method, after refactoring the existing 223 // TODO: Move it outside this method, after refactoring the existing
225 // unit tests. Specifically: 224 // unit tests. Specifically:
226 // (1) Make sure that AutocompleteMatch.keyword is set iff there is 225 // (1) Make sure that AutocompleteMatch.keyword is set iff there is
227 // a corresponding call to RegisterTemplateURL; otherwise the 226 // a corresponding call to RegisterTemplateURL; otherwise the
228 // controller flow will crash; this practically means that 227 // controller flow will crash; this practically means that
229 // RunTests/ResetControllerXXX/RegisterTemplateURL should 228 // RunTests/ResetControllerXXX/RegisterTemplateURL should
230 // be coordinated with each other. 229 // be coordinated with each other.
231 // (2) Inject test arguments rather than rely on the hardcoded values, e.g. 230 // (2) Inject test arguments rather than rely on the hardcoded values, e.g.
232 // don't rely on kResultsPerProvided and default relevance ordering 231 // don't rely on kResultsPerProvided and default relevance ordering
233 // (B > A). 232 // (B > A).
234 RegisterTemplateURL(ASCIIToUTF16(kTestTemplateURLKeyword), 233 RegisterTemplateURL(ASCIIToUTF16(kTestTemplateURLKeyword),
235 "http://aqs/{searchTerms}/{google:assistedQueryStats}"); 234 "http://aqs/{searchTerms}/{google:assistedQueryStats}");
236 235
236 ACProviders providers;
237
237 // Construct two new providers, with either the same or different prefixes. 238 // Construct two new providers, with either the same or different prefixes.
238 TestProvider* providerA = 239 TestProvider* provider1 = new TestProvider(
239 new TestProvider(kResultsPerProvider, 240 kResultsPerProvider,
240 ASCIIToUTF16("http://a"), 241 ASCIIToUTF16("http://a"),
241 &profile_, 242 &profile_,
242 ASCIIToUTF16(kTestTemplateURLKeyword)); 243 ASCIIToUTF16(kTestTemplateURLKeyword));
243 providerA->AddRef(); 244 provider1->AddRef();
244 providers_.push_back(providerA); 245 providers.push_back(provider1);
245 246
246 TestProvider* providerB = new TestProvider( 247 TestProvider* provider2 = new TestProvider(
247 kResultsPerProvider * 2, 248 kResultsPerProvider * 2,
248 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), 249 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"),
249 &profile_, 250 &profile_,
250 string16()); 251 string16());
251 providerB->AddRef(); 252 provider2->AddRef();
252 providers_.push_back(providerB); 253 providers.push_back(provider2);
253 254
254 // Reset the controller to contain our new providers. 255 // Reset the controller to contain our new providers.
255 AutocompleteController* controller = 256 controller_.reset(new AutocompleteController(&profile_, NULL, 0));
256 new AutocompleteController(providers_, &profile_); 257 controller_->providers_.swap(providers);
257 controller_.reset(controller); 258 provider1->set_listener(controller_.get());
258 providerA->set_listener(controller); 259 provider2->set_listener(controller_.get());
259 providerB->set_listener(controller);
260 260
261 // The providers don't complete synchronously, so listen for "result updated" 261 // The providers don't complete synchronously, so listen for "result updated"
262 // notifications. 262 // notifications.
263 registrar_.Add(this, 263 registrar_.Add(this,
264 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 264 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
265 content::Source<AutocompleteController>(controller)); 265 content::Source<AutocompleteController>(controller_.get()));
266
267 if (provider1_ptr)
268 *provider1_ptr = provider1;
269 if (provider2_ptr)
270 *provider2_ptr = provider2;
266 } 271 }
267 272
268 void AutocompleteProviderTest:: 273 void AutocompleteProviderTest::
269 ResetControllerWithTestProvidersWithKeywordAndSearchProviders() { 274 ResetControllerWithKeywordAndSearchProviders() {
270 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 275 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
271 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); 276 &profile_, &TemplateURLServiceFactory::BuildInstanceFor);
272 277
273 // Reset the default TemplateURL. 278 // Reset the default TemplateURL.
274 TemplateURLData data; 279 TemplateURLData data;
275 data.SetURL("http://defaultturl/{searchTerms}"); 280 data.SetURL("http://defaultturl/{searchTerms}");
276 TemplateURL* default_t_url = new TemplateURL(&profile_, data); 281 TemplateURL* default_t_url = new TemplateURL(&profile_, data);
277 TemplateURLService* turl_model = 282 TemplateURLService* turl_model =
278 TemplateURLServiceFactory::GetForProfile(&profile_); 283 TemplateURLServiceFactory::GetForProfile(&profile_);
279 turl_model->Add(default_t_url); 284 turl_model->Add(default_t_url);
280 turl_model->SetDefaultSearchProvider(default_t_url); 285 turl_model->SetDefaultSearchProvider(default_t_url);
281 TemplateURLID default_provider_id = default_t_url->id(); 286 TemplateURLID default_provider_id = default_t_url->id();
282 ASSERT_NE(0, default_provider_id); 287 ASSERT_NE(0, default_provider_id);
283 288
284 // Create another TemplateURL for KeywordProvider. 289 // Create another TemplateURL for KeywordProvider.
285 data.short_name = ASCIIToUTF16("k"); 290 data.short_name = ASCIIToUTF16("k");
286 data.SetKeyword(ASCIIToUTF16("k")); 291 data.SetKeyword(ASCIIToUTF16("k"));
287 data.SetURL("http://keyword/{searchTerms}"); 292 data.SetURL("http://keyword/{searchTerms}");
288 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data); 293 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data);
289 turl_model->Add(keyword_t_url); 294 turl_model->Add(keyword_t_url);
290 ASSERT_NE(0, keyword_t_url->id()); 295 ASSERT_NE(0, keyword_t_url->id());
291 296
292 // Forget about any existing providers. The controller owns them and will 297 controller_.reset(new AutocompleteController(
293 // Release() them below, when we delete it during the call to reset(). 298 &profile_, NULL,
294 providers_.clear(); 299 AutocompleteProvider::TYPE_KEYWORD | AutocompleteProvider::TYPE_SEARCH));
295
296 // Create both a keyword and search provider, and add them in that order.
297 // (Order is important; see comments in RunExactKeymatchTest().)
298 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_);
299 keyword_provider->AddRef();
300 providers_.push_back(keyword_provider);
301 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_);
302 search_provider->AddRef();
303 providers_.push_back(search_provider);
304
305 controller_.reset(new AutocompleteController(providers_, &profile_));
306 } 300 }
307 301
308 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() { 302 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() {
309 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 303 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
310 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); 304 &profile_, &TemplateURLServiceFactory::BuildInstanceFor);
311 305
312 TemplateURLService* turl_model = 306 TemplateURLService* turl_model =
313 TemplateURLServiceFactory::GetForProfile(&profile_); 307 TemplateURLServiceFactory::GetForProfile(&profile_);
314 308
315 // Create a TemplateURL for KeywordProvider. 309 // Create a TemplateURL for KeywordProvider.
316 TemplateURLData data; 310 TemplateURLData data;
317 data.short_name = ASCIIToUTF16("foo.com"); 311 data.short_name = ASCIIToUTF16("foo.com");
318 data.SetKeyword(ASCIIToUTF16("foo.com")); 312 data.SetKeyword(ASCIIToUTF16("foo.com"));
319 data.SetURL("http://foo.com/{searchTerms}"); 313 data.SetURL("http://foo.com/{searchTerms}");
320 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data); 314 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data);
321 turl_model->Add(keyword_t_url); 315 turl_model->Add(keyword_t_url);
322 ASSERT_NE(0, keyword_t_url->id()); 316 ASSERT_NE(0, keyword_t_url->id());
323 317
324 // Create another TemplateURL for KeywordProvider. 318 // Create another TemplateURL for KeywordProvider.
325 data.short_name = ASCIIToUTF16("bar.com"); 319 data.short_name = ASCIIToUTF16("bar.com");
326 data.SetKeyword(ASCIIToUTF16("bar.com")); 320 data.SetKeyword(ASCIIToUTF16("bar.com"));
327 data.SetURL("http://bar.com/{searchTerms}"); 321 data.SetURL("http://bar.com/{searchTerms}");
328 keyword_t_url = new TemplateURL(&profile_, data); 322 keyword_t_url = new TemplateURL(&profile_, data);
329 turl_model->Add(keyword_t_url); 323 turl_model->Add(keyword_t_url);
330 ASSERT_NE(0, keyword_t_url->id()); 324 ASSERT_NE(0, keyword_t_url->id());
331 325
332 // Forget about any existing providers. The controller owns them and will 326 controller_.reset(new AutocompleteController(
333 // Release() them below, when we delete it during the call to reset(). 327 &profile_, NULL, AutocompleteProvider::TYPE_KEYWORD));
334 providers_.clear();
335
336 // Create both a keyword and search provider, and add them in that order.
337 // (Order is important; see comments in RunExactKeymatchTest().)
338 KeywordProvider* keyword_provider = new KeywordProvider(NULL, &profile_);
339 keyword_provider->AddRef();
340 providers_.push_back(keyword_provider);
341
342 AutocompleteController* controller =
343 new AutocompleteController(providers_, &profile_);
344 controller->set_keyword_provider(keyword_provider);
345 controller_.reset(controller);
346 } 328 }
347 329
348 void AutocompleteProviderTest::RunTest() { 330 void AutocompleteProviderTest::RunTest() {
349 RunQuery(ASCIIToUTF16("a")); 331 RunQuery(ASCIIToUTF16("a"));
350 } 332 }
351 333
352 void AutocompleteProviderTest::RunRedundantKeywordTest( 334 void AutocompleteProviderTest::RunRedundantKeywordTest(
353 const KeywordTestData* match_data, 335 const KeywordTestData* match_data,
354 size_t size) { 336 size_t size) {
355 ACMatches matches; 337 ACMatches matches;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 void AutocompleteProviderTest::RunExactKeymatchTest( 394 void AutocompleteProviderTest::RunExactKeymatchTest(
413 bool allow_exact_keyword_match) { 395 bool allow_exact_keyword_match) {
414 // Send the controller input which exactly matches the keyword provider we 396 // Send the controller input which exactly matches the keyword provider we
415 // created in ResetControllerWithKeywordAndSearchProviders(). The default 397 // created in ResetControllerWithKeywordAndSearchProviders(). The default
416 // match should thus be a keyword match iff |allow_exact_keyword_match| is 398 // match should thus be a keyword match iff |allow_exact_keyword_match| is
417 // true. 399 // true.
418 controller_->Start(ASCIIToUTF16("k test"), string16(), true, false, 400 controller_->Start(ASCIIToUTF16("k test"), string16(), true, false,
419 allow_exact_keyword_match, 401 allow_exact_keyword_match,
420 AutocompleteInput::SYNCHRONOUS_MATCHES); 402 AutocompleteInput::SYNCHRONOUS_MATCHES);
421 EXPECT_TRUE(controller_->done()); 403 EXPECT_TRUE(controller_->done());
422 // ResetControllerWithKeywordAndSearchProviders() adds the keyword provider 404 EXPECT_EQ(allow_exact_keyword_match ?
423 // first, then the search provider. So if the default match is a keyword 405 AutocompleteProvider::TYPE_KEYWORD : AutocompleteProvider::TYPE_SEARCH,
424 // match, it will come from provider 0, otherwise from provider 1. 406 controller_->result().default_match()->provider->type());
425 EXPECT_EQ(providers_[allow_exact_keyword_match ? 0 : 1],
426 controller_->result().default_match()->provider);
427 } 407 }
428 408
429 void AutocompleteProviderTest::Observe( 409 void AutocompleteProviderTest::Observe(
430 int type, 410 int type,
431 const content::NotificationSource& source, 411 const content::NotificationSource& source,
432 const content::NotificationDetails& details) { 412 const content::NotificationDetails& details) {
433 if (controller_->done()) { 413 if (controller_->done()) {
434 result_.CopyFrom(controller_->result()); 414 result_.CopyFrom(controller_->result());
435 MessageLoop::current()->Quit(); 415 MessageLoop::current()->Quit();
436 } 416 }
437 } 417 }
438 418
439 // Tests that the default selection is set properly when updating results. 419 // Tests that the default selection is set properly when updating results.
440 TEST_F(AutocompleteProviderTest, Query) { 420 TEST_F(AutocompleteProviderTest, Query) {
441 ResetControllerWithTestProviders(false); 421 TestProvider* provider1 = NULL;
422 TestProvider* provider2 = NULL;
423 ResetControllerWithTestProviders(false, &provider1, &provider2);
442 RunTest(); 424 RunTest();
443 425
444 // Make sure the default match gets set to the highest relevance match. The 426 // Make sure the default match gets set to the highest relevance match. The
445 // highest relevance matches should come from the second provider. 427 // highest relevance matches should come from the second provider.
446 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers 428 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers
447 ASSERT_NE(result_.end(), result_.default_match()); 429 ASSERT_NE(result_.end(), result_.default_match());
448 EXPECT_EQ(providers_[1], result_.default_match()->provider); 430 EXPECT_EQ(provider2, result_.default_match()->provider);
449 } 431 }
450 432
451 // Tests assisted query stats. 433 // Tests assisted query stats.
452 TEST_F(AutocompleteProviderTest, AssistedQueryStats) { 434 TEST_F(AutocompleteProviderTest, AssistedQueryStats) {
453 ResetControllerWithTestProviders(false); 435 ResetControllerWithTestProviders(false, NULL, NULL);
454 RunTest(); 436 RunTest();
455 437
456 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers 438 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers
457 439
458 // Now, check the results from the second provider, as they should not have 440 // Now, check the results from the second provider, as they should not have
459 // assisted query stats set. 441 // assisted query stats set.
460 for (size_t i = 0; i < kResultsPerProvider; ++i) { 442 for (size_t i = 0; i < kResultsPerProvider; ++i) {
461 EXPECT_TRUE( 443 EXPECT_TRUE(
462 result_.match_at(i)->search_terms_args->assisted_query_stats.empty()); 444 result_.match_at(i)->search_terms_args->assisted_query_stats.empty());
463 } 445 }
464 // The first provider has a test keyword, so AQS should be non-empty. 446 // The first provider has a test keyword, so AQS should be non-empty.
465 for (size_t i = kResultsPerProvider; i < kResultsPerProvider * 2; ++i) { 447 for (size_t i = kResultsPerProvider; i < kResultsPerProvider * 2; ++i) {
466 EXPECT_FALSE( 448 EXPECT_FALSE(
467 result_.match_at(i)->search_terms_args->assisted_query_stats.empty()); 449 result_.match_at(i)->search_terms_args->assisted_query_stats.empty());
468 } 450 }
469 } 451 }
470 452
471 TEST_F(AutocompleteProviderTest, RemoveDuplicates) { 453 TEST_F(AutocompleteProviderTest, RemoveDuplicates) {
472 ResetControllerWithTestProviders(true); 454 TestProvider* provider1 = NULL;
455 TestProvider* provider2 = NULL;
456 ResetControllerWithTestProviders(true, &provider1, &provider2);
473 RunTest(); 457 RunTest();
474 458
475 // Make sure all the first provider's results were eliminated by the second 459 // Make sure all the first provider's results were eliminated by the second
476 // provider's. 460 // provider's.
477 EXPECT_EQ(kResultsPerProvider, result_.size()); 461 EXPECT_EQ(kResultsPerProvider, result_.size());
478 for (AutocompleteResult::const_iterator i(result_.begin()); 462 for (AutocompleteResult::const_iterator i(result_.begin());
479 i != result_.end(); ++i) 463 i != result_.end(); ++i)
480 EXPECT_EQ(providers_[1], i->provider); 464 EXPECT_EQ(provider2, i->provider);
481 } 465 }
482 466
483 TEST_F(AutocompleteProviderTest, AllowExactKeywordMatch) { 467 TEST_F(AutocompleteProviderTest, AllowExactKeywordMatch) {
484 ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); 468 ResetControllerWithKeywordAndSearchProviders();
485 RunExactKeymatchTest(true); 469 RunExactKeymatchTest(true);
486 RunExactKeymatchTest(false); 470 RunExactKeymatchTest(false);
487 } 471 }
488 472
489 // Test that redundant associated keywords are removed. 473 // Test that redundant associated keywords are removed.
490 TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) { 474 TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) {
491 ResetControllerWithKeywordProvider(); 475 ResetControllerWithKeywordProvider();
492 476
493 // Get the controller's internal members in the correct state. 477 // Get the controller's internal members in the correct state.
494 RunQuery(ASCIIToUTF16("fo")); 478 RunQuery(ASCIIToUTF16("fo"));
(...skipping 27 matching lines...) Expand all
522 { ASCIIToUTF16("bar.com"), string16(), true }, 506 { ASCIIToUTF16("bar.com"), string16(), true },
523 }; 507 };
524 508
525 SCOPED_TRACE("Duplicate url with multiple keywords"); 509 SCOPED_TRACE("Duplicate url with multiple keywords");
526 RunRedundantKeywordTest(multiple_keyword, 510 RunRedundantKeywordTest(multiple_keyword,
527 ARRAYSIZE_UNSAFE(multiple_keyword)); 511 ARRAYSIZE_UNSAFE(multiple_keyword));
528 } 512 }
529 } 513 }
530 514
531 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) { 515 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
532 ResetControllerWithTestProviders(false); 516 ResetControllerWithTestProviders(false, NULL, NULL);
533 517
534 { 518 {
535 AssistedQueryStatsTestData test_data[] = { 519 AssistedQueryStatsTestData test_data[] = {
536 // MSVC doesn't support zero-length arrays, so supply some dummy data. 520 // MSVC doesn't support zero-length arrays, so supply some dummy data.
537 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "" } 521 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "" }
538 }; 522 };
539 SCOPED_TRACE("No matches"); 523 SCOPED_TRACE("No matches");
540 // Note: We pass 0 here to ignore the dummy data above. 524 // Note: We pass 0 here to ignore the dummy data above.
541 RunAssistedQueryStatsTest(test_data, 0); 525 RunAssistedQueryStatsTest(test_data, 0);
542 } 526 }
(...skipping 14 matching lines...) Expand all
557 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, 541 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" },
558 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, 542 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" },
559 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, 543 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" },
560 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, 544 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" },
561 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, 545 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" },
562 }; 546 };
563 SCOPED_TRACE("Multiple matches"); 547 SCOPED_TRACE("Multiple matches");
564 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); 548 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
565 } 549 }
566 } 550 }
567
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_provider.cc ('k') | chrome/browser/autocomplete/builtin_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698