| OLD | NEW |
| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 const size_t kResultsPerProvider = 3; | 39 const size_t kResultsPerProvider = 3; |
| 40 const char kTestTemplateURLKeyword[] = "t"; | 40 const char kTestTemplateURLKeyword[] = "t"; |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Autocomplete provider that provides known results. Note that this is | 43 // Autocomplete provider that provides known results. Note that this is |
| 44 // refcounted so that it can also be a task on the message loop. | 44 // refcounted so that it can also be a task on the message loop. |
| 45 class TestProvider : public AutocompleteProvider { | 45 class TestProvider : public AutocompleteProvider { |
| 46 public: | 46 public: |
| 47 TestProvider(int relevance, const string16& prefix, | 47 TestProvider(int relevance, const base::string16& prefix, |
| 48 Profile* profile, | 48 Profile* profile, |
| 49 const string16 match_keyword) | 49 const base::string16 match_keyword) |
| 50 : AutocompleteProvider(NULL, profile, AutocompleteProvider::TYPE_SEARCH), | 50 : AutocompleteProvider(NULL, profile, AutocompleteProvider::TYPE_SEARCH), |
| 51 relevance_(relevance), | 51 relevance_(relevance), |
| 52 prefix_(prefix), | 52 prefix_(prefix), |
| 53 match_keyword_(match_keyword) { | 53 match_keyword_(match_keyword) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 virtual void Start(const AutocompleteInput& input, | 56 virtual void Start(const AutocompleteInput& input, |
| 57 bool minimal_changes) OVERRIDE; | 57 bool minimal_changes) OVERRIDE; |
| 58 | 58 |
| 59 void set_listener(AutocompleteProviderListener* listener) { | 59 void set_listener(AutocompleteProviderListener* listener) { |
| 60 listener_ = listener; | 60 listener_ = listener; |
| 61 } | 61 } |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 virtual ~TestProvider() {} | 64 virtual ~TestProvider() {} |
| 65 | 65 |
| 66 void Run(); | 66 void Run(); |
| 67 | 67 |
| 68 void AddResults(int start_at, int num); | 68 void AddResults(int start_at, int num); |
| 69 void AddResultsWithSearchTermsArgs( | 69 void AddResultsWithSearchTermsArgs( |
| 70 int start_at, | 70 int start_at, |
| 71 int num, | 71 int num, |
| 72 AutocompleteMatch::Type type, | 72 AutocompleteMatch::Type type, |
| 73 const TemplateURLRef::SearchTermsArgs& search_terms_args); | 73 const TemplateURLRef::SearchTermsArgs& search_terms_args); |
| 74 | 74 |
| 75 int relevance_; | 75 int relevance_; |
| 76 const string16 prefix_; | 76 const base::string16 prefix_; |
| 77 const string16 match_keyword_; | 77 const base::string16 match_keyword_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 void TestProvider::Start(const AutocompleteInput& input, | 80 void TestProvider::Start(const AutocompleteInput& input, |
| 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. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 108 AddResults(1, kResultsPerProvider); | 108 AddResults(1, kResultsPerProvider); |
| 109 done_ = true; | 109 done_ = true; |
| 110 DCHECK(listener_); | 110 DCHECK(listener_); |
| 111 listener_->OnProviderUpdate(true); | 111 listener_->OnProviderUpdate(true); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void TestProvider::AddResults(int start_at, int num) { | 114 void TestProvider::AddResults(int start_at, int num) { |
| 115 AddResultsWithSearchTermsArgs(start_at, | 115 AddResultsWithSearchTermsArgs(start_at, |
| 116 num, | 116 num, |
| 117 AutocompleteMatchType::URL_WHAT_YOU_TYPED, | 117 AutocompleteMatchType::URL_WHAT_YOU_TYPED, |
| 118 TemplateURLRef::SearchTermsArgs(string16())); | 118 TemplateURLRef::SearchTermsArgs( |
| 119 base::string16())); |
| 119 } | 120 } |
| 120 | 121 |
| 121 void TestProvider::AddResultsWithSearchTermsArgs( | 122 void TestProvider::AddResultsWithSearchTermsArgs( |
| 122 int start_at, | 123 int start_at, |
| 123 int num, | 124 int num, |
| 124 AutocompleteMatch::Type type, | 125 AutocompleteMatch::Type type, |
| 125 const TemplateURLRef::SearchTermsArgs& search_terms_args) { | 126 const TemplateURLRef::SearchTermsArgs& search_terms_args) { |
| 126 for (int i = start_at; i < num; i++) { | 127 for (int i = start_at; i < num; i++) { |
| 127 AutocompleteMatch match(this, relevance_ - i, false, type); | 128 AutocompleteMatch match(this, relevance_ - i, false, type); |
| 128 | 129 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 144 } | 145 } |
| 145 | 146 |
| 146 matches_.push_back(match); | 147 matches_.push_back(match); |
| 147 } | 148 } |
| 148 } | 149 } |
| 149 | 150 |
| 150 class AutocompleteProviderTest : public testing::Test, | 151 class AutocompleteProviderTest : public testing::Test, |
| 151 public content::NotificationObserver { | 152 public content::NotificationObserver { |
| 152 protected: | 153 protected: |
| 153 struct KeywordTestData { | 154 struct KeywordTestData { |
| 154 const string16 fill_into_edit; | 155 const base::string16 fill_into_edit; |
| 155 const string16 keyword; | 156 const base::string16 keyword; |
| 156 const bool expected_keyword_result; | 157 const bool expected_keyword_result; |
| 157 }; | 158 }; |
| 158 | 159 |
| 159 struct AssistedQueryStatsTestData { | 160 struct AssistedQueryStatsTestData { |
| 160 const AutocompleteMatch::Type match_type; | 161 const AutocompleteMatch::Type match_type; |
| 161 const std::string expected_aqs; | 162 const std::string expected_aqs; |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 protected: | 165 protected: |
| 165 // Registers a test TemplateURL under the given keyword. | 166 // Registers a test TemplateURL under the given keyword. |
| 166 void RegisterTemplateURL(const string16 keyword, | 167 void RegisterTemplateURL(const base::string16 keyword, |
| 167 const std::string& template_url); | 168 const std::string& template_url); |
| 168 | 169 |
| 169 // Resets |controller_| with two TestProviders. |provider1_ptr| and | 170 // Resets |controller_| with two TestProviders. |provider1_ptr| and |
| 170 // |provider2_ptr| are updated to point to the new providers if non-NULL. | 171 // |provider2_ptr| are updated to point to the new providers if non-NULL. |
| 171 void ResetControllerWithTestProviders(bool same_destinations, | 172 void ResetControllerWithTestProviders(bool same_destinations, |
| 172 TestProvider** provider1_ptr, | 173 TestProvider** provider1_ptr, |
| 173 TestProvider** provider2_ptr); | 174 TestProvider** provider2_ptr); |
| 174 | 175 |
| 175 // Runs a query on the input "a", and makes sure both providers' input is | 176 // Runs a query on the input "a", and makes sure both providers' input is |
| 176 // properly collected. | 177 // properly collected. |
| 177 void RunTest(); | 178 void RunTest(); |
| 178 | 179 |
| 179 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); | 180 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); |
| 180 | 181 |
| 181 void RunAssistedQueryStatsTest( | 182 void RunAssistedQueryStatsTest( |
| 182 const AssistedQueryStatsTestData* aqs_test_data, | 183 const AssistedQueryStatsTestData* aqs_test_data, |
| 183 size_t size); | 184 size_t size); |
| 184 | 185 |
| 185 void RunQuery(const string16 query); | 186 void RunQuery(const base::string16 query); |
| 186 | 187 |
| 187 void ResetControllerWithKeywordAndSearchProviders(); | 188 void ResetControllerWithKeywordAndSearchProviders(); |
| 188 void ResetControllerWithKeywordProvider(); | 189 void ResetControllerWithKeywordProvider(); |
| 189 void RunExactKeymatchTest(bool allow_exact_keyword_match); | 190 void RunExactKeymatchTest(bool allow_exact_keyword_match); |
| 190 | 191 |
| 191 void CopyResults(); | 192 void CopyResults(); |
| 192 | 193 |
| 193 // Returns match.destination_url as it would be set by | 194 // Returns match.destination_url as it would be set by |
| 194 // AutocompleteController::UpdateMatchDestinationURL(). | 195 // AutocompleteController::UpdateMatchDestinationURL(). |
| 195 GURL GetDestinationURL(AutocompleteMatch match, | 196 GURL GetDestinationURL(AutocompleteMatch match, |
| 196 base::TimeDelta query_formulation_time) const; | 197 base::TimeDelta query_formulation_time) const; |
| 197 | 198 |
| 198 AutocompleteResult result_; | 199 AutocompleteResult result_; |
| 199 scoped_ptr<AutocompleteController> controller_; | 200 scoped_ptr<AutocompleteController> controller_; |
| 200 | 201 |
| 201 private: | 202 private: |
| 202 // content::NotificationObserver: | 203 // content::NotificationObserver: |
| 203 virtual void Observe(int type, | 204 virtual void Observe(int type, |
| 204 const content::NotificationSource& source, | 205 const content::NotificationSource& source, |
| 205 const content::NotificationDetails& details) OVERRIDE; | 206 const content::NotificationDetails& details) OVERRIDE; |
| 206 | 207 |
| 207 base::MessageLoopForUI message_loop_; | 208 base::MessageLoopForUI message_loop_; |
| 208 content::NotificationRegistrar registrar_; | 209 content::NotificationRegistrar registrar_; |
| 209 TestingProfile profile_; | 210 TestingProfile profile_; |
| 210 }; | 211 }; |
| 211 | 212 |
| 212 void AutocompleteProviderTest::RegisterTemplateURL( | 213 void AutocompleteProviderTest::RegisterTemplateURL( |
| 213 const string16 keyword, | 214 const base::string16 keyword, |
| 214 const std::string& template_url) { | 215 const std::string& template_url) { |
| 215 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 216 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 216 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); | 217 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); |
| 217 TemplateURLData data; | 218 TemplateURLData data; |
| 218 data.SetURL(template_url); | 219 data.SetURL(template_url); |
| 219 data.SetKeyword(keyword); | 220 data.SetKeyword(keyword); |
| 220 TemplateURL* default_t_url = new TemplateURL(&profile_, data); | 221 TemplateURL* default_t_url = new TemplateURL(&profile_, data); |
| 221 TemplateURLService* turl_model = | 222 TemplateURLService* turl_model = |
| 222 TemplateURLServiceFactory::GetForProfile(&profile_); | 223 TemplateURLServiceFactory::GetForProfile(&profile_); |
| 223 turl_model->Add(default_t_url); | 224 turl_model->Add(default_t_url); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 252 ASCIIToUTF16("http://a"), | 253 ASCIIToUTF16("http://a"), |
| 253 &profile_, | 254 &profile_, |
| 254 ASCIIToUTF16(kTestTemplateURLKeyword)); | 255 ASCIIToUTF16(kTestTemplateURLKeyword)); |
| 255 provider1->AddRef(); | 256 provider1->AddRef(); |
| 256 providers.push_back(provider1); | 257 providers.push_back(provider1); |
| 257 | 258 |
| 258 TestProvider* provider2 = new TestProvider( | 259 TestProvider* provider2 = new TestProvider( |
| 259 kResultsPerProvider * 2, | 260 kResultsPerProvider * 2, |
| 260 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), | 261 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), |
| 261 &profile_, | 262 &profile_, |
| 262 string16()); | 263 base::string16()); |
| 263 provider2->AddRef(); | 264 provider2->AddRef(); |
| 264 providers.push_back(provider2); | 265 providers.push_back(provider2); |
| 265 | 266 |
| 266 // Reset the controller to contain our new providers. | 267 // Reset the controller to contain our new providers. |
| 267 controller_.reset(new AutocompleteController(&profile_, NULL, 0)); | 268 controller_.reset(new AutocompleteController(&profile_, NULL, 0)); |
| 268 // We're going to swap the providers vector, but the old vector should be | 269 // We're going to swap the providers vector, but the old vector should be |
| 269 // empty so no elements need to be freed at this point. | 270 // empty so no elements need to be freed at this point. |
| 270 EXPECT_TRUE(controller_->providers_.empty()); | 271 EXPECT_TRUE(controller_->providers_.empty()); |
| 271 controller_->providers_.swap(providers); | 272 controller_->providers_.swap(providers); |
| 272 provider1->set_listener(controller_.get()); | 273 provider1->set_listener(controller_.get()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 size_t size) { | 375 size_t size) { |
| 375 // Prepare input. | 376 // Prepare input. |
| 376 const size_t kMaxRelevance = 1000; | 377 const size_t kMaxRelevance = 1000; |
| 377 ACMatches matches; | 378 ACMatches matches; |
| 378 for (size_t i = 0; i < size; ++i) { | 379 for (size_t i = 0; i < size; ++i) { |
| 379 AutocompleteMatch match(NULL, kMaxRelevance - i, false, | 380 AutocompleteMatch match(NULL, kMaxRelevance - i, false, |
| 380 aqs_test_data[i].match_type); | 381 aqs_test_data[i].match_type); |
| 381 match.allowed_to_be_default_match = true; | 382 match.allowed_to_be_default_match = true; |
| 382 match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword); | 383 match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword); |
| 383 match.search_terms_args.reset( | 384 match.search_terms_args.reset( |
| 384 new TemplateURLRef::SearchTermsArgs(string16())); | 385 new TemplateURLRef::SearchTermsArgs(base::string16())); |
| 385 matches.push_back(match); | 386 matches.push_back(match); |
| 386 } | 387 } |
| 387 result_.Reset(); | 388 result_.Reset(); |
| 388 result_.AppendMatches(matches); | 389 result_.AppendMatches(matches); |
| 389 | 390 |
| 390 // Update AQS. | 391 // Update AQS. |
| 391 controller_->UpdateAssistedQueryStats(&result_); | 392 controller_->UpdateAssistedQueryStats(&result_); |
| 392 | 393 |
| 393 // Verify data. | 394 // Verify data. |
| 394 for (size_t i = 0; i < size; ++i) { | 395 for (size_t i = 0; i < size; ++i) { |
| 395 EXPECT_EQ(aqs_test_data[i].expected_aqs, | 396 EXPECT_EQ(aqs_test_data[i].expected_aqs, |
| 396 result_.match_at(i)->search_terms_args->assisted_query_stats); | 397 result_.match_at(i)->search_terms_args->assisted_query_stats); |
| 397 } | 398 } |
| 398 } | 399 } |
| 399 | 400 |
| 400 void AutocompleteProviderTest::RunQuery(const string16 query) { | 401 void AutocompleteProviderTest::RunQuery(const base::string16 query) { |
| 401 result_.Reset(); | 402 result_.Reset(); |
| 402 controller_->Start(AutocompleteInput( | 403 controller_->Start(AutocompleteInput( |
| 403 query, string16::npos, string16(), GURL(), | 404 query, base::string16::npos, base::string16(), GURL(), |
| 404 AutocompleteInput::INVALID_SPEC, true, false, true, | 405 AutocompleteInput::INVALID_SPEC, true, false, true, |
| 405 AutocompleteInput::ALL_MATCHES)); | 406 AutocompleteInput::ALL_MATCHES)); |
| 406 | 407 |
| 407 if (!controller_->done()) | 408 if (!controller_->done()) |
| 408 // The message loop will terminate when all autocomplete input has been | 409 // The message loop will terminate when all autocomplete input has been |
| 409 // collected. | 410 // collected. |
| 410 base::MessageLoop::current()->Run(); | 411 base::MessageLoop::current()->Run(); |
| 411 } | 412 } |
| 412 | 413 |
| 413 void AutocompleteProviderTest::RunExactKeymatchTest( | 414 void AutocompleteProviderTest::RunExactKeymatchTest( |
| 414 bool allow_exact_keyword_match) { | 415 bool allow_exact_keyword_match) { |
| 415 // Send the controller input which exactly matches the keyword provider we | 416 // Send the controller input which exactly matches the keyword provider we |
| 416 // created in ResetControllerWithKeywordAndSearchProviders(). The default | 417 // created in ResetControllerWithKeywordAndSearchProviders(). The default |
| 417 // match should thus be a search-other-engine match iff | 418 // match should thus be a search-other-engine match iff |
| 418 // |allow_exact_keyword_match| is true. Regardless, the match should | 419 // |allow_exact_keyword_match| is true. Regardless, the match should |
| 419 // be from SearchProvider. (It provides all verbatim search matches, | 420 // be from SearchProvider. (It provides all verbatim search matches, |
| 420 // keyword or not.) | 421 // keyword or not.) |
| 421 controller_->Start(AutocompleteInput( | 422 controller_->Start(AutocompleteInput( |
| 422 ASCIIToUTF16("k test"), string16::npos, string16(), GURL(), | 423 ASCIIToUTF16("k test"), base::string16::npos, base::string16(), GURL(), |
| 423 AutocompleteInput::INVALID_SPEC, true, false, allow_exact_keyword_match, | 424 AutocompleteInput::INVALID_SPEC, true, false, allow_exact_keyword_match, |
| 424 AutocompleteInput::SYNCHRONOUS_MATCHES)); | 425 AutocompleteInput::SYNCHRONOUS_MATCHES)); |
| 425 EXPECT_TRUE(controller_->done()); | 426 EXPECT_TRUE(controller_->done()); |
| 426 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH, | 427 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH, |
| 427 controller_->result().default_match()->provider->type()); | 428 controller_->result().default_match()->provider->type()); |
| 428 EXPECT_EQ(allow_exact_keyword_match ? | 429 EXPECT_EQ(allow_exact_keyword_match ? |
| 429 AutocompleteMatchType::SEARCH_OTHER_ENGINE : | 430 AutocompleteMatchType::SEARCH_OTHER_ENGINE : |
| 430 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 431 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
| 431 controller_->result().default_match()->type); | 432 controller_->result().default_match()->type); |
| 432 } | 433 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 EXPECT_EQ("http://defaultturl/k%20test?a=b", | 521 EXPECT_EQ("http://defaultturl/k%20test?a=b", |
| 521 result_.match_at(1)->destination_url.possibly_invalid_spec()); | 522 result_.match_at(1)->destination_url.possibly_invalid_spec()); |
| 522 } | 523 } |
| 523 | 524 |
| 524 // Test that redundant associated keywords are removed. | 525 // Test that redundant associated keywords are removed. |
| 525 TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) { | 526 TEST_F(AutocompleteProviderTest, RedundantKeywordsIgnoredInResult) { |
| 526 ResetControllerWithKeywordProvider(); | 527 ResetControllerWithKeywordProvider(); |
| 527 | 528 |
| 528 { | 529 { |
| 529 KeywordTestData duplicate_url[] = { | 530 KeywordTestData duplicate_url[] = { |
| 530 { ASCIIToUTF16("fo"), string16(), false }, | 531 { ASCIIToUTF16("fo"), base::string16(), false }, |
| 531 { ASCIIToUTF16("foo.com"), string16(), true }, | 532 { ASCIIToUTF16("foo.com"), base::string16(), true }, |
| 532 { ASCIIToUTF16("foo.com"), string16(), false } | 533 { ASCIIToUTF16("foo.com"), base::string16(), false } |
| 533 }; | 534 }; |
| 534 | 535 |
| 535 SCOPED_TRACE("Duplicate url"); | 536 SCOPED_TRACE("Duplicate url"); |
| 536 RunRedundantKeywordTest(duplicate_url, ARRAYSIZE_UNSAFE(duplicate_url)); | 537 RunRedundantKeywordTest(duplicate_url, ARRAYSIZE_UNSAFE(duplicate_url)); |
| 537 } | 538 } |
| 538 | 539 |
| 539 { | 540 { |
| 540 KeywordTestData keyword_match[] = { | 541 KeywordTestData keyword_match[] = { |
| 541 { ASCIIToUTF16("foo.com"), ASCIIToUTF16("foo.com"), false }, | 542 { ASCIIToUTF16("foo.com"), ASCIIToUTF16("foo.com"), false }, |
| 542 { ASCIIToUTF16("foo.com"), string16(), false } | 543 { ASCIIToUTF16("foo.com"), base::string16(), false } |
| 543 }; | 544 }; |
| 544 | 545 |
| 545 SCOPED_TRACE("Duplicate url with keyword match"); | 546 SCOPED_TRACE("Duplicate url with keyword match"); |
| 546 RunRedundantKeywordTest(keyword_match, ARRAYSIZE_UNSAFE(keyword_match)); | 547 RunRedundantKeywordTest(keyword_match, ARRAYSIZE_UNSAFE(keyword_match)); |
| 547 } | 548 } |
| 548 | 549 |
| 549 { | 550 { |
| 550 KeywordTestData multiple_keyword[] = { | 551 KeywordTestData multiple_keyword[] = { |
| 551 { ASCIIToUTF16("fo"), string16(), false }, | 552 { ASCIIToUTF16("fo"), base::string16(), false }, |
| 552 { ASCIIToUTF16("foo.com"), string16(), true }, | 553 { ASCIIToUTF16("foo.com"), base::string16(), true }, |
| 553 { ASCIIToUTF16("foo.com"), string16(), false }, | 554 { ASCIIToUTF16("foo.com"), base::string16(), false }, |
| 554 { ASCIIToUTF16("bar.com"), string16(), true }, | 555 { ASCIIToUTF16("bar.com"), base::string16(), true }, |
| 555 }; | 556 }; |
| 556 | 557 |
| 557 SCOPED_TRACE("Duplicate url with multiple keywords"); | 558 SCOPED_TRACE("Duplicate url with multiple keywords"); |
| 558 RunRedundantKeywordTest(multiple_keyword, | 559 RunRedundantKeywordTest(multiple_keyword, |
| 559 ARRAYSIZE_UNSAFE(multiple_keyword)); | 560 ARRAYSIZE_UNSAFE(multiple_keyword)); |
| 560 } | 561 } |
| 561 } | 562 } |
| 562 | 563 |
| 563 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) { | 564 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) { |
| 564 ResetControllerWithTestProviders(false, NULL, NULL); | 565 ResetControllerWithTestProviders(false, NULL, NULL); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 622 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 622 EXPECT_TRUE(url.path().empty()); | 623 EXPECT_TRUE(url.path().empty()); |
| 623 | 624 |
| 624 // There needs to be a keyword provider. | 625 // There needs to be a keyword provider. |
| 625 match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword); | 626 match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword); |
| 626 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 627 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 627 EXPECT_TRUE(url.path().empty()); | 628 EXPECT_TRUE(url.path().empty()); |
| 628 | 629 |
| 629 // search_terms_args needs to be set. | 630 // search_terms_args needs to be set. |
| 630 match.search_terms_args.reset( | 631 match.search_terms_args.reset( |
| 631 new TemplateURLRef::SearchTermsArgs(string16())); | 632 new TemplateURLRef::SearchTermsArgs(base::string16())); |
| 632 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 633 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 633 EXPECT_TRUE(url.path().empty()); | 634 EXPECT_TRUE(url.path().empty()); |
| 634 | 635 |
| 635 // assisted_query_stats needs to have been previously set. | 636 // assisted_query_stats needs to have been previously set. |
| 636 match.search_terms_args->assisted_query_stats = | 637 match.search_terms_args->assisted_query_stats = |
| 637 "chrome.0.69i57j69i58j5l2j0l3j69i59"; | 638 "chrome.0.69i57j69i58j5l2j0l3j69i59"; |
| 638 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 639 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 639 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j0&", url.path()); | 640 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j0&", url.path()); |
| 640 | 641 |
| 641 // Test field trial triggered bit set. | 642 // Test field trial triggered bit set. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 653 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 654 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 654 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); | 655 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); |
| 655 | 656 |
| 656 // Test page classification and field trial triggered set. | 657 // Test page classification and field trial triggered set. |
| 657 controller_->search_provider_->field_trial_triggered_in_session_ = true; | 658 controller_->search_provider_->field_trial_triggered_in_session_ = true; |
| 658 EXPECT_TRUE( | 659 EXPECT_TRUE( |
| 659 controller_->search_provider_->field_trial_triggered_in_session()); | 660 controller_->search_provider_->field_trial_triggered_in_session()); |
| 660 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 661 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 661 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); | 662 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); |
| 662 } | 663 } |
| OLD | NEW |