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

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

Issue 109013006: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 12 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 bool minimal_changes) { 81 bool minimal_changes) {
82 if (minimal_changes) 82 if (minimal_changes)
83 return; 83 return;
84 84
85 matches_.clear(); 85 matches_.clear();
86 86
87 // Generate 4 results synchronously, the rest later. 87 // Generate 4 results synchronously, the rest later.
88 AddResults(0, 1); 88 AddResults(0, 1);
89 AddResultsWithSearchTermsArgs( 89 AddResultsWithSearchTermsArgs(
90 1, 1, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, 90 1, 1, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
91 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("echo"))); 91 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("echo")));
92 AddResultsWithSearchTermsArgs( 92 AddResultsWithSearchTermsArgs(
93 2, 1, AutocompleteMatchType::NAVSUGGEST, 93 2, 1, AutocompleteMatchType::NAVSUGGEST,
94 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("nav"))); 94 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("nav")));
95 AddResultsWithSearchTermsArgs( 95 AddResultsWithSearchTermsArgs(
96 3, 1, AutocompleteMatchType::SEARCH_SUGGEST, 96 3, 1, AutocompleteMatchType::SEARCH_SUGGEST,
97 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("query"))); 97 TemplateURLRef::SearchTermsArgs(base::ASCIIToUTF16("query")));
98 98
99 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { 99 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) {
100 done_ = false; 100 done_ = false;
101 base::MessageLoop::current()->PostTask( 101 base::MessageLoop::current()->PostTask(
102 FROM_HERE, base::Bind(&TestProvider::Run, this)); 102 FROM_HERE, base::Bind(&TestProvider::Run, this));
103 } 103 }
104 } 104 }
105 105
106 void TestProvider::Run() { 106 void TestProvider::Run() {
107 DCHECK_GT(kResultsPerProvider, 0U); 107 DCHECK_GT(kResultsPerProvider, 0U);
(...skipping 12 matching lines...) Expand all
120 } 120 }
121 121
122 void TestProvider::AddResultsWithSearchTermsArgs( 122 void TestProvider::AddResultsWithSearchTermsArgs(
123 int start_at, 123 int start_at,
124 int num, 124 int num,
125 AutocompleteMatch::Type type, 125 AutocompleteMatch::Type type,
126 const TemplateURLRef::SearchTermsArgs& search_terms_args) { 126 const TemplateURLRef::SearchTermsArgs& search_terms_args) {
127 for (int i = start_at; i < num; i++) { 127 for (int i = start_at; i < num; i++) {
128 AutocompleteMatch match(this, relevance_ - i, false, type); 128 AutocompleteMatch match(this, relevance_ - i, false, type);
129 129
130 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i)); 130 match.fill_into_edit = prefix_ + base::UTF8ToUTF16(base::IntToString(i));
131 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit)); 131 match.destination_url = GURL(base::UTF16ToUTF8(match.fill_into_edit));
132 match.allowed_to_be_default_match = true; 132 match.allowed_to_be_default_match = true;
133 133
134 match.contents = match.fill_into_edit; 134 match.contents = match.fill_into_edit;
135 match.contents_class.push_back( 135 match.contents_class.push_back(
136 ACMatchClassification(0, ACMatchClassification::NONE)); 136 ACMatchClassification(0, ACMatchClassification::NONE));
137 match.description = match.fill_into_edit; 137 match.description = match.fill_into_edit;
138 match.description_class.push_back( 138 match.description_class.push_back(
139 ACMatchClassification(0, ACMatchClassification::NONE)); 139 ACMatchClassification(0, ACMatchClassification::NONE));
140 match.search_terms_args.reset( 140 match.search_terms_args.reset(
141 new TemplateURLRef::SearchTermsArgs(search_terms_args)); 141 new TemplateURLRef::SearchTermsArgs(search_terms_args));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // TODO: Move it outside this method, after refactoring the existing 235 // TODO: Move it outside this method, after refactoring the existing
236 // unit tests. Specifically: 236 // unit tests. Specifically:
237 // (1) Make sure that AutocompleteMatch.keyword is set iff there is 237 // (1) Make sure that AutocompleteMatch.keyword is set iff there is
238 // a corresponding call to RegisterTemplateURL; otherwise the 238 // a corresponding call to RegisterTemplateURL; otherwise the
239 // controller flow will crash; this practically means that 239 // controller flow will crash; this practically means that
240 // RunTests/ResetControllerXXX/RegisterTemplateURL should 240 // RunTests/ResetControllerXXX/RegisterTemplateURL should
241 // be coordinated with each other. 241 // be coordinated with each other.
242 // (2) Inject test arguments rather than rely on the hardcoded values, e.g. 242 // (2) Inject test arguments rather than rely on the hardcoded values, e.g.
243 // don't rely on kResultsPerProvided and default relevance ordering 243 // don't rely on kResultsPerProvided and default relevance ordering
244 // (B > A). 244 // (B > A).
245 RegisterTemplateURL(ASCIIToUTF16(kTestTemplateURLKeyword), 245 RegisterTemplateURL(base::ASCIIToUTF16(kTestTemplateURLKeyword),
246 "http://aqs/{searchTerms}/{google:assistedQueryStats}"); 246 "http://aqs/{searchTerms}/{google:assistedQueryStats}");
247 247
248 ACProviders providers; 248 ACProviders providers;
249 249
250 // Construct two new providers, with either the same or different prefixes. 250 // Construct two new providers, with either the same or different prefixes.
251 TestProvider* provider1 = new TestProvider( 251 TestProvider* provider1 = new TestProvider(
252 kResultsPerProvider, 252 kResultsPerProvider,
253 ASCIIToUTF16("http://a"), 253 base::ASCIIToUTF16("http://a"),
254 &profile_, 254 &profile_,
255 ASCIIToUTF16(kTestTemplateURLKeyword)); 255 base::ASCIIToUTF16(kTestTemplateURLKeyword));
256 provider1->AddRef(); 256 provider1->AddRef();
257 providers.push_back(provider1); 257 providers.push_back(provider1);
258 258
259 TestProvider* provider2 = new TestProvider( 259 TestProvider* provider2 = new TestProvider(
260 kResultsPerProvider * 2, 260 kResultsPerProvider * 2,
261 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), 261 same_destinations ? base::ASCIIToUTF16("http://a")
262 : base::ASCIIToUTF16("http://b"),
262 &profile_, 263 &profile_,
263 base::string16()); 264 base::string16());
264 provider2->AddRef(); 265 provider2->AddRef();
265 providers.push_back(provider2); 266 providers.push_back(provider2);
266 267
267 // Reset the controller to contain our new providers. 268 // Reset the controller to contain our new providers.
268 controller_.reset(new AutocompleteController(&profile_, NULL, 0)); 269 controller_.reset(new AutocompleteController(&profile_, NULL, 0));
269 // We're going to swap the providers vector, but the old vector should be 270 // We're going to swap the providers vector, but the old vector should be
270 // empty so no elements need to be freed at this point. 271 // empty so no elements need to be freed at this point.
271 EXPECT_TRUE(controller_->providers_.empty()); 272 EXPECT_TRUE(controller_->providers_.empty());
(...skipping 23 matching lines...) Expand all
295 data.SetURL("http://defaultturl/{searchTerms}"); 296 data.SetURL("http://defaultturl/{searchTerms}");
296 TemplateURL* default_t_url = new TemplateURL(&profile_, data); 297 TemplateURL* default_t_url = new TemplateURL(&profile_, data);
297 TemplateURLService* turl_model = 298 TemplateURLService* turl_model =
298 TemplateURLServiceFactory::GetForProfile(&profile_); 299 TemplateURLServiceFactory::GetForProfile(&profile_);
299 turl_model->Add(default_t_url); 300 turl_model->Add(default_t_url);
300 turl_model->SetDefaultSearchProvider(default_t_url); 301 turl_model->SetDefaultSearchProvider(default_t_url);
301 TemplateURLID default_provider_id = default_t_url->id(); 302 TemplateURLID default_provider_id = default_t_url->id();
302 ASSERT_NE(0, default_provider_id); 303 ASSERT_NE(0, default_provider_id);
303 304
304 // Create another TemplateURL for KeywordProvider. 305 // Create another TemplateURL for KeywordProvider.
305 data.short_name = ASCIIToUTF16("k"); 306 data.short_name = base::ASCIIToUTF16("k");
306 data.SetKeyword(ASCIIToUTF16("k")); 307 data.SetKeyword(base::ASCIIToUTF16("k"));
307 data.SetURL("http://keyword/{searchTerms}"); 308 data.SetURL("http://keyword/{searchTerms}");
308 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data); 309 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data);
309 turl_model->Add(keyword_t_url); 310 turl_model->Add(keyword_t_url);
310 ASSERT_NE(0, keyword_t_url->id()); 311 ASSERT_NE(0, keyword_t_url->id());
311 312
312 controller_.reset(new AutocompleteController( 313 controller_.reset(new AutocompleteController(
313 &profile_, NULL, 314 &profile_, NULL,
314 AutocompleteProvider::TYPE_KEYWORD | AutocompleteProvider::TYPE_SEARCH)); 315 AutocompleteProvider::TYPE_KEYWORD | AutocompleteProvider::TYPE_SEARCH));
315 } 316 }
316 317
317 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() { 318 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() {
318 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 319 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
319 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); 320 &profile_, &TemplateURLServiceFactory::BuildInstanceFor);
320 321
321 TemplateURLService* turl_model = 322 TemplateURLService* turl_model =
322 TemplateURLServiceFactory::GetForProfile(&profile_); 323 TemplateURLServiceFactory::GetForProfile(&profile_);
323 324
324 // Create a TemplateURL for KeywordProvider. 325 // Create a TemplateURL for KeywordProvider.
325 TemplateURLData data; 326 TemplateURLData data;
326 data.short_name = ASCIIToUTF16("foo.com"); 327 data.short_name = base::ASCIIToUTF16("foo.com");
327 data.SetKeyword(ASCIIToUTF16("foo.com")); 328 data.SetKeyword(base::ASCIIToUTF16("foo.com"));
328 data.SetURL("http://foo.com/{searchTerms}"); 329 data.SetURL("http://foo.com/{searchTerms}");
329 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data); 330 TemplateURL* keyword_t_url = new TemplateURL(&profile_, data);
330 turl_model->Add(keyword_t_url); 331 turl_model->Add(keyword_t_url);
331 ASSERT_NE(0, keyword_t_url->id()); 332 ASSERT_NE(0, keyword_t_url->id());
332 333
333 // Create another TemplateURL for KeywordProvider. 334 // Create another TemplateURL for KeywordProvider.
334 data.short_name = ASCIIToUTF16("bar.com"); 335 data.short_name = base::ASCIIToUTF16("bar.com");
335 data.SetKeyword(ASCIIToUTF16("bar.com")); 336 data.SetKeyword(base::ASCIIToUTF16("bar.com"));
336 data.SetURL("http://bar.com/{searchTerms}"); 337 data.SetURL("http://bar.com/{searchTerms}");
337 keyword_t_url = new TemplateURL(&profile_, data); 338 keyword_t_url = new TemplateURL(&profile_, data);
338 turl_model->Add(keyword_t_url); 339 turl_model->Add(keyword_t_url);
339 ASSERT_NE(0, keyword_t_url->id()); 340 ASSERT_NE(0, keyword_t_url->id());
340 341
341 controller_.reset(new AutocompleteController( 342 controller_.reset(new AutocompleteController(
342 &profile_, NULL, AutocompleteProvider::TYPE_KEYWORD)); 343 &profile_, NULL, AutocompleteProvider::TYPE_KEYWORD));
343 } 344 }
344 345
345 void AutocompleteProviderTest::RunTest() { 346 void AutocompleteProviderTest::RunTest() {
346 RunQuery(ASCIIToUTF16("a")); 347 RunQuery(base::ASCIIToUTF16("a"));
347 } 348 }
348 349
349 void AutocompleteProviderTest::RunRedundantKeywordTest( 350 void AutocompleteProviderTest::RunRedundantKeywordTest(
350 const KeywordTestData* match_data, 351 const KeywordTestData* match_data,
351 size_t size) { 352 size_t size) {
352 ACMatches matches; 353 ACMatches matches;
353 for (size_t i = 0; i < size; ++i) { 354 for (size_t i = 0; i < size; ++i) {
354 AutocompleteMatch match; 355 AutocompleteMatch match;
355 match.relevance = 1000; // Arbitrary non-zero value. 356 match.relevance = 1000; // Arbitrary non-zero value.
356 match.allowed_to_be_default_match = true; 357 match.allowed_to_be_default_match = true;
(...skipping 16 matching lines...) Expand all
373 void AutocompleteProviderTest::RunAssistedQueryStatsTest( 374 void AutocompleteProviderTest::RunAssistedQueryStatsTest(
374 const AssistedQueryStatsTestData* aqs_test_data, 375 const AssistedQueryStatsTestData* aqs_test_data,
375 size_t size) { 376 size_t size) {
376 // Prepare input. 377 // Prepare input.
377 const size_t kMaxRelevance = 1000; 378 const size_t kMaxRelevance = 1000;
378 ACMatches matches; 379 ACMatches matches;
379 for (size_t i = 0; i < size; ++i) { 380 for (size_t i = 0; i < size; ++i) {
380 AutocompleteMatch match(NULL, kMaxRelevance - i, false, 381 AutocompleteMatch match(NULL, kMaxRelevance - i, false,
381 aqs_test_data[i].match_type); 382 aqs_test_data[i].match_type);
382 match.allowed_to_be_default_match = true; 383 match.allowed_to_be_default_match = true;
383 match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword); 384 match.keyword = base::ASCIIToUTF16(kTestTemplateURLKeyword);
384 match.search_terms_args.reset( 385 match.search_terms_args.reset(
385 new TemplateURLRef::SearchTermsArgs(base::string16())); 386 new TemplateURLRef::SearchTermsArgs(base::string16()));
386 matches.push_back(match); 387 matches.push_back(match);
387 } 388 }
388 result_.Reset(); 389 result_.Reset();
389 result_.AppendMatches(matches); 390 result_.AppendMatches(matches);
390 391
391 // Update AQS. 392 // Update AQS.
392 controller_->UpdateAssistedQueryStats(&result_); 393 controller_->UpdateAssistedQueryStats(&result_);
393 394
(...skipping 19 matching lines...) Expand all
413 414
414 void AutocompleteProviderTest::RunExactKeymatchTest( 415 void AutocompleteProviderTest::RunExactKeymatchTest(
415 bool allow_exact_keyword_match) { 416 bool allow_exact_keyword_match) {
416 // Send the controller input which exactly matches the keyword provider we 417 // Send the controller input which exactly matches the keyword provider we
417 // created in ResetControllerWithKeywordAndSearchProviders(). The default 418 // created in ResetControllerWithKeywordAndSearchProviders(). The default
418 // match should thus be a search-other-engine match iff 419 // match should thus be a search-other-engine match iff
419 // |allow_exact_keyword_match| is true. Regardless, the match should 420 // |allow_exact_keyword_match| is true. Regardless, the match should
420 // be from SearchProvider. (It provides all verbatim search matches, 421 // be from SearchProvider. (It provides all verbatim search matches,
421 // keyword or not.) 422 // keyword or not.)
422 controller_->Start(AutocompleteInput( 423 controller_->Start(AutocompleteInput(
423 ASCIIToUTF16("k test"), base::string16::npos, base::string16(), GURL(), 424 base::ASCIIToUTF16("k test"), base::string16::npos, base::string16(),
424 AutocompleteInput::INVALID_SPEC, true, false, allow_exact_keyword_match, 425 GURL(), AutocompleteInput::INVALID_SPEC, true, false,
425 AutocompleteInput::SYNCHRONOUS_MATCHES)); 426 allow_exact_keyword_match, AutocompleteInput::SYNCHRONOUS_MATCHES));
426 EXPECT_TRUE(controller_->done()); 427 EXPECT_TRUE(controller_->done());
427 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH, 428 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH,
428 controller_->result().default_match()->provider->type()); 429 controller_->result().default_match()->provider->type());
429 EXPECT_EQ(allow_exact_keyword_match ? 430 EXPECT_EQ(allow_exact_keyword_match ?
430 AutocompleteMatchType::SEARCH_OTHER_ENGINE : 431 AutocompleteMatchType::SEARCH_OTHER_ENGINE :
431 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, 432 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
432 controller_->result().default_match()->type); 433 controller_->result().default_match()->type);
433 } 434 }
434 435
435 void AutocompleteProviderTest::CopyResults() { 436 void AutocompleteProviderTest::CopyResults() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 EXPECT_EQ("http://defaultturl/k%20test?a=b", 522 EXPECT_EQ("http://defaultturl/k%20test?a=b",
522 result_.match_at(1)->destination_url.possibly_invalid_spec()); 523 result_.match_at(1)->destination_url.possibly_invalid_spec());
523 } 524 }
524 525
525 // Test that redundant associated keywords are removed. 526 // Test that redundant associated keywords are removed.
526 TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) { 527 TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) {
527 ResetControllerWithKeywordProvider(); 528 ResetControllerWithKeywordProvider();
528 529
529 { 530 {
530 KeywordTestData duplicate_url[] = { 531 KeywordTestData duplicate_url[] = {
531 { ASCIIToUTF16("fo"), base::string16(), false }, 532 { base::ASCIIToUTF16("fo"), base::string16(), false },
532 { ASCIIToUTF16("foo.com"), base::string16(), true }, 533 { base::ASCIIToUTF16("foo.com"), base::string16(), true },
533 { ASCIIToUTF16("foo.com"), base::string16(), false } 534 { base::ASCIIToUTF16("foo.com"), base::string16(), false }
534 }; 535 };
535 536
536 SCOPED_TRACE("Duplicate url"); 537 SCOPED_TRACE("Duplicate url");
537 RunRedundantKeywordTest(duplicate_url, ARRAYSIZE_UNSAFE(duplicate_url)); 538 RunRedundantKeywordTest(duplicate_url, ARRAYSIZE_UNSAFE(duplicate_url));
538 } 539 }
539 540
540 { 541 {
541 KeywordTestData keyword_match[] = { 542 KeywordTestData keyword_match[] = {
542 { ASCIIToUTF16("foo.com"), ASCIIToUTF16("foo.com"), false }, 543 { base::ASCIIToUTF16("foo.com"), base::ASCIIToUTF16("foo.com"), false },
543 { ASCIIToUTF16("foo.com"), base::string16(), false } 544 { base::ASCIIToUTF16("foo.com"), base::string16(), false }
544 }; 545 };
545 546
546 SCOPED_TRACE("Duplicate url with keyword match"); 547 SCOPED_TRACE("Duplicate url with keyword match");
547 RunRedundantKeywordTest(keyword_match, ARRAYSIZE_UNSAFE(keyword_match)); 548 RunRedundantKeywordTest(keyword_match, ARRAYSIZE_UNSAFE(keyword_match));
548 } 549 }
549 550
550 { 551 {
551 KeywordTestData multiple_keyword[] = { 552 KeywordTestData multiple_keyword[] = {
552 { ASCIIToUTF16("fo"), base::string16(), false }, 553 { base::ASCIIToUTF16("fo"), base::string16(), false },
553 { ASCIIToUTF16("foo.com"), base::string16(), true }, 554 { base::ASCIIToUTF16("foo.com"), base::string16(), true },
554 { ASCIIToUTF16("foo.com"), base::string16(), false }, 555 { base::ASCIIToUTF16("foo.com"), base::string16(), false },
555 { ASCIIToUTF16("bar.com"), base::string16(), true }, 556 { base::ASCIIToUTF16("bar.com"), base::string16(), true },
556 }; 557 };
557 558
558 SCOPED_TRACE("Duplicate url with multiple keywords"); 559 SCOPED_TRACE("Duplicate url with multiple keywords");
559 RunRedundantKeywordTest(multiple_keyword, 560 RunRedundantKeywordTest(multiple_keyword,
560 ARRAYSIZE_UNSAFE(multiple_keyword)); 561 ARRAYSIZE_UNSAFE(multiple_keyword));
561 } 562 }
562 } 563 }
563 564
564 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) { 565 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
565 ResetControllerWithTestProviders(false, NULL, NULL); 566 ResetControllerWithTestProviders(false, NULL, NULL);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 ResetControllerWithKeywordAndSearchProviders(); 611 ResetControllerWithKeywordAndSearchProviders();
611 612
612 // For the destination URL to have aqs parameters for query formulation time 613 // For the destination URL to have aqs parameters for query formulation time
613 // and the field trial triggered bit, many conditions need to be satisfied. 614 // and the field trial triggered bit, many conditions need to be satisfied.
614 AutocompleteMatch match(NULL, 1100, false, 615 AutocompleteMatch match(NULL, 1100, false,
615 AutocompleteMatchType::SEARCH_SUGGEST); 616 AutocompleteMatchType::SEARCH_SUGGEST);
616 GURL url(GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456))); 617 GURL url(GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)));
617 EXPECT_TRUE(url.path().empty()); 618 EXPECT_TRUE(url.path().empty());
618 619
619 // The protocol needs to be https. 620 // The protocol needs to be https.
620 RegisterTemplateURL(ASCIIToUTF16(kTestTemplateURLKeyword), 621 RegisterTemplateURL(base::ASCIIToUTF16(kTestTemplateURLKeyword),
621 "https://aqs/{searchTerms}/{google:assistedQueryStats}"); 622 "https://aqs/{searchTerms}/{google:assistedQueryStats}");
622 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 623 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
623 EXPECT_TRUE(url.path().empty()); 624 EXPECT_TRUE(url.path().empty());
624 625
625 // There needs to be a keyword provider. 626 // There needs to be a keyword provider.
626 match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword); 627 match.keyword = base::ASCIIToUTF16(kTestTemplateURLKeyword);
627 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 628 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
628 EXPECT_TRUE(url.path().empty()); 629 EXPECT_TRUE(url.path().empty());
629 630
630 // search_terms_args needs to be set. 631 // search_terms_args needs to be set.
631 match.search_terms_args.reset( 632 match.search_terms_args.reset(
632 new TemplateURLRef::SearchTermsArgs(base::string16())); 633 new TemplateURLRef::SearchTermsArgs(base::string16()));
633 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 634 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
634 EXPECT_TRUE(url.path().empty()); 635 EXPECT_TRUE(url.path().empty());
635 636
636 // assisted_query_stats needs to have been previously set. 637 // assisted_query_stats needs to have been previously set.
(...skipping 17 matching lines...) Expand all
654 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 655 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
655 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); 656 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path());
656 657
657 // Test page classification and field trial triggered set. 658 // Test page classification and field trial triggered set.
658 controller_->search_provider_->field_trial_triggered_in_session_ = true; 659 controller_->search_provider_->field_trial_triggered_in_session_ = true;
659 EXPECT_TRUE( 660 EXPECT_TRUE(
660 controller_->search_provider_->field_trial_triggered_in_session()); 661 controller_->search_provider_->field_trial_triggered_in_session());
661 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 662 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
662 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); 663 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path());
663 } 664 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_provider.cc ('k') | chrome/browser/autocomplete/autocomplete_result.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698