| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/omnibox/search_provider.h" | 5 #include "components/omnibox/search_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 const bool allowed_to_be_default_match; | 135 const bool allowed_to_be_default_match; |
| 136 const base::string16 fill_into_edit; | 136 const base::string16 fill_into_edit; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 struct TestData { | 139 struct TestData { |
| 140 const base::string16 input; | 140 const base::string16 input; |
| 141 const size_t num_results; | 141 const size_t num_results; |
| 142 const ResultInfo output[3]; | 142 const ResultInfo output[3]; |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 struct ExpectedMatch { |
| 146 std::string contents; |
| 147 bool allowed_to_be_default_match; |
| 148 }; |
| 149 |
| 145 SearchProviderTest() | 150 SearchProviderTest() |
| 146 : default_t_url_(NULL), | 151 : default_t_url_(NULL), |
| 147 term1_(ASCIIToUTF16("term1")), | 152 term1_(ASCIIToUTF16("term1")), |
| 148 keyword_t_url_(NULL), | 153 keyword_t_url_(NULL), |
| 149 keyword_term_(ASCIIToUTF16("keyword")), | 154 keyword_term_(ASCIIToUTF16("keyword")), |
| 150 run_loop_(NULL) { | 155 run_loop_(NULL) { |
| 151 ResetFieldTrialList(); | 156 ResetFieldTrialList(); |
| 152 } | 157 } |
| 153 | 158 |
| 154 // See description above class for what this registers. | 159 // See description above class for what this registers. |
| 155 virtual void SetUp() OVERRIDE; | 160 virtual void SetUp() OVERRIDE; |
| 156 virtual void TearDown() OVERRIDE; | 161 virtual void TearDown() OVERRIDE; |
| 157 | 162 |
| 158 void RunTest(TestData* cases, int num_cases, bool prefer_keyword); | 163 void RunTest(TestData* cases, int num_cases, bool prefer_keyword); |
| 159 | 164 |
| 160 protected: | 165 protected: |
| 161 // Needed for AutocompleteFieldTrial::ActivateStaticTrials(); | 166 // Needed for AutocompleteFieldTrial::ActivateStaticTrials(); |
| 162 scoped_ptr<base::FieldTrialList> field_trial_list_; | 167 scoped_ptr<base::FieldTrialList> field_trial_list_; |
| 163 | 168 |
| 164 // Default value used for testing. | 169 // Default values used for testing. |
| 165 static const std::string kNotApplicable; | 170 static const std::string kNotApplicable; |
| 171 static const ExpectedMatch kEmptyExpectedMatch; |
| 166 | 172 |
| 167 // Adds a search for |term|, using the engine |t_url| to the history, and | 173 // Adds a search for |term|, using the engine |t_url| to the history, and |
| 168 // returns the URL for that search. | 174 // returns the URL for that search. |
| 169 GURL AddSearchToHistory(TemplateURL* t_url, base::string16 term, int visit_cou
nt); | 175 GURL AddSearchToHistory(TemplateURL* t_url, base::string16 term, int visit_cou
nt); |
| 170 | 176 |
| 171 // Looks for a match in |provider_| with |contents| equal to |contents|. | 177 // Looks for a match in |provider_| with |contents| equal to |contents|. |
| 172 // Sets |match| to it if found. Returns whether |match| was set. | 178 // Sets |match| to it if found. Returns whether |match| was set. |
| 173 bool FindMatchWithContents(const base::string16& contents, | 179 bool FindMatchWithContents(const base::string16& contents, |
| 174 AutocompleteMatch* match); | 180 AutocompleteMatch* match); |
| 175 | 181 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 188 // Invokes Start on provider_, then runs all pending tasks. | 194 // Invokes Start on provider_, then runs all pending tasks. |
| 189 void QueryForInput(const base::string16& text, | 195 void QueryForInput(const base::string16& text, |
| 190 bool prevent_inline_autocomplete, | 196 bool prevent_inline_autocomplete, |
| 191 bool prefer_keyword); | 197 bool prefer_keyword); |
| 192 | 198 |
| 193 // Calls QueryForInput(), finishes any suggest query, then if |wyt_match| is | 199 // Calls QueryForInput(), finishes any suggest query, then if |wyt_match| is |
| 194 // non-NULL, sets it to the "what you typed" entry for |text|. | 200 // non-NULL, sets it to the "what you typed" entry for |text|. |
| 195 void QueryForInputAndSetWYTMatch(const base::string16& text, | 201 void QueryForInputAndSetWYTMatch(const base::string16& text, |
| 196 AutocompleteMatch* wyt_match); | 202 AutocompleteMatch* wyt_match); |
| 197 | 203 |
| 204 // Calls QueryForInput(), sets the JSON responses for the default and keyword |
| 205 // fetchers, and waits until the responses have been returned and the matches |
| 206 // returned. Use empty responses for each fetcher that shouldn't be set up / |
| 207 // configured. |
| 208 void QueryForInputAndWaitForFetcherResponses( |
| 209 const base::string16& text, |
| 210 const bool prefer_keyword, |
| 211 const std::string& default_fetcher_response, |
| 212 const std::string& keyword_fetcher_response); |
| 213 |
| 198 // Notifies the URLFetcher for the suggest query corresponding to the default | 214 // Notifies the URLFetcher for the suggest query corresponding to the default |
| 199 // search provider that it's done. | 215 // search provider that it's done. |
| 200 // Be sure and wrap calls to this in ASSERT_NO_FATAL_FAILURE. | 216 // Be sure and wrap calls to this in ASSERT_NO_FATAL_FAILURE. |
| 201 void FinishDefaultSuggestQuery(); | 217 void FinishDefaultSuggestQuery(); |
| 202 | 218 |
| 203 // Runs SearchProvider on |input|, for which the suggest server replies | 219 // Runs SearchProvider on |input|, for which the suggest server replies |
| 204 // with |json|, and expects that the resulting matches' contents equals | 220 // with |json|, and expects that the resulting matches' contents equals |
| 205 // that in |matches|. An empty entry in |matches| means no match should | 221 // that in |matches|. An empty entry in |matches| means no match should |
| 206 // be returned in that position. Reports any errors with a message that | 222 // be returned in that position. Reports any errors with a message that |
| 207 // includes |error_description|. | 223 // includes |error_description|. |
| 208 void ForcedQueryTestHelper(const std::string& input, | 224 void ForcedQueryTestHelper(const std::string& input, |
| 209 const std::string& json, | 225 const std::string& json, |
| 210 const std::string matches[3], | 226 const std::string matches[3], |
| 211 const std::string& error_description); | 227 const std::string& error_description); |
| 212 | 228 |
| 229 // Verifies that |matches| and |expected_matches| agree on the first |
| 230 // |num_expected_matches|, displaying an error message that includes |
| 231 // |description| for any disagreement. |
| 232 void CheckMatches(const std::string& description, |
| 233 const size_t num_expected_matches, |
| 234 const ExpectedMatch expected_matches[], |
| 235 const ACMatches& matches); |
| 236 |
| 213 void ResetFieldTrialList(); | 237 void ResetFieldTrialList(); |
| 214 | 238 |
| 215 // Create a field trial, with ZeroSuggest activation based on |enabled|. | 239 // Create a field trial, with ZeroSuggest activation based on |enabled|. |
| 216 base::FieldTrial* CreateZeroSuggestFieldTrial(bool enabled); | 240 base::FieldTrial* CreateZeroSuggestFieldTrial(bool enabled); |
| 217 | 241 |
| 218 void ClearAllResults(); | 242 void ClearAllResults(); |
| 219 | 243 |
| 220 // See description above class for details of these fields. | 244 // See description above class for details of these fields. |
| 221 TemplateURL* default_t_url_; | 245 TemplateURL* default_t_url_; |
| 222 const base::string16 term1_; | 246 const base::string16 term1_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 237 scoped_refptr<SearchProviderForTest> provider_; | 261 scoped_refptr<SearchProviderForTest> provider_; |
| 238 | 262 |
| 239 // If non-NULL, OnProviderUpdate quits the current |run_loop_|. | 263 // If non-NULL, OnProviderUpdate quits the current |run_loop_|. |
| 240 base::RunLoop* run_loop_; | 264 base::RunLoop* run_loop_; |
| 241 | 265 |
| 242 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); | 266 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); |
| 243 }; | 267 }; |
| 244 | 268 |
| 245 // static | 269 // static |
| 246 const std::string SearchProviderTest::kNotApplicable = "Not Applicable"; | 270 const std::string SearchProviderTest::kNotApplicable = "Not Applicable"; |
| 271 const SearchProviderTest::ExpectedMatch |
| 272 SearchProviderTest::kEmptyExpectedMatch = { kNotApplicable, false }; |
| 247 | 273 |
| 248 void SearchProviderTest::SetUp() { | 274 void SearchProviderTest::SetUp() { |
| 249 // Make sure that fetchers are automatically ungregistered upon destruction. | 275 // Make sure that fetchers are automatically ungregistered upon destruction. |
| 250 test_factory_.set_remove_fetcher_on_delete(true); | 276 test_factory_.set_remove_fetcher_on_delete(true); |
| 251 | 277 |
| 252 // We need both the history service and template url model loaded. | 278 // We need both the history service and template url model loaded. |
| 253 ASSERT_TRUE(profile_.CreateHistoryService(true, false)); | 279 ASSERT_TRUE(profile_.CreateHistoryService(true, false)); |
| 254 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 280 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 255 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); | 281 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); |
| 256 | 282 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 bool prefer_keyword) { | 337 bool prefer_keyword) { |
| 312 ACMatches matches; | 338 ACMatches matches; |
| 313 for (int i = 0; i < num_cases; ++i) { | 339 for (int i = 0; i < num_cases; ++i) { |
| 314 AutocompleteInput input(cases[i].input, base::string16::npos, | 340 AutocompleteInput input(cases[i].input, base::string16::npos, |
| 315 base::string16(), GURL(), | 341 base::string16(), GURL(), |
| 316 metrics::OmniboxEventProto::INVALID_SPEC, false, | 342 metrics::OmniboxEventProto::INVALID_SPEC, false, |
| 317 prefer_keyword, true, true, | 343 prefer_keyword, true, true, |
| 318 ChromeAutocompleteSchemeClassifier(&profile_)); | 344 ChromeAutocompleteSchemeClassifier(&profile_)); |
| 319 provider_->Start(input, false); | 345 provider_->Start(input, false); |
| 320 matches = provider_->matches(); | 346 matches = provider_->matches(); |
| 321 base::string16 diagnostic_details = | 347 SCOPED_TRACE( |
| 322 ASCIIToUTF16("Input was: ") + | 348 ASCIIToUTF16("Input was: ") + |
| 323 cases[i].input + | 349 cases[i].input + |
| 324 ASCIIToUTF16("; prefer_keyword was: ") + | 350 ASCIIToUTF16("; prefer_keyword was: ") + |
| 325 (prefer_keyword ? ASCIIToUTF16("true") : ASCIIToUTF16("false")); | 351 (prefer_keyword ? ASCIIToUTF16("true") : ASCIIToUTF16("false"))); |
| 326 EXPECT_EQ(cases[i].num_results, matches.size()) << diagnostic_details; | 352 EXPECT_EQ(cases[i].num_results, matches.size()); |
| 327 if (matches.size() == cases[i].num_results) { | 353 if (matches.size() == cases[i].num_results) { |
| 328 for (size_t j = 0; j < cases[i].num_results; ++j) { | 354 for (size_t j = 0; j < cases[i].num_results; ++j) { |
| 329 EXPECT_EQ(cases[i].output[j].gurl, matches[j].destination_url) << | 355 EXPECT_EQ(cases[i].output[j].gurl, matches[j].destination_url); |
| 330 diagnostic_details; | 356 EXPECT_EQ(cases[i].output[j].result_type, matches[j].type); |
| 331 EXPECT_EQ(cases[i].output[j].result_type, matches[j].type) << | |
| 332 diagnostic_details; | |
| 333 EXPECT_EQ(cases[i].output[j].fill_into_edit, | 357 EXPECT_EQ(cases[i].output[j].fill_into_edit, |
| 334 matches[j].fill_into_edit) << diagnostic_details; | 358 matches[j].fill_into_edit); |
| 335 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, | 359 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, |
| 336 matches[j].allowed_to_be_default_match) << diagnostic_details; | 360 matches[j].allowed_to_be_default_match); |
| 337 } | 361 } |
| 338 } | 362 } |
| 339 } | 363 } |
| 340 } | 364 } |
| 341 | 365 |
| 342 void SearchProviderTest::OnProviderUpdate(bool updated_matches) { | 366 void SearchProviderTest::OnProviderUpdate(bool updated_matches) { |
| 343 if (run_loop_ && provider_->done()) { | 367 if (run_loop_ && provider_->done()) { |
| 344 run_loop_->Quit(); | 368 run_loop_->Quit(); |
| 345 run_loop_ = NULL; | 369 run_loop_ = NULL; |
| 346 } | 370 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 ASSERT_GE(provider_->matches().size(), 1u); | 405 ASSERT_GE(provider_->matches().size(), 1u); |
| 382 EXPECT_TRUE(FindMatchWithDestination( | 406 EXPECT_TRUE(FindMatchWithDestination( |
| 383 GURL(default_t_url_->url_ref().ReplaceSearchTerms( | 407 GURL(default_t_url_->url_ref().ReplaceSearchTerms( |
| 384 TemplateURLRef::SearchTermsArgs(base::CollapseWhitespace( | 408 TemplateURLRef::SearchTermsArgs(base::CollapseWhitespace( |
| 385 text, false)), | 409 text, false)), |
| 386 TemplateURLServiceFactory::GetForProfile( | 410 TemplateURLServiceFactory::GetForProfile( |
| 387 &profile_)->search_terms_data())), | 411 &profile_)->search_terms_data())), |
| 388 wyt_match)); | 412 wyt_match)); |
| 389 } | 413 } |
| 390 | 414 |
| 415 void SearchProviderTest::QueryForInputAndWaitForFetcherResponses( |
| 416 const base::string16& text, |
| 417 const bool prefer_keyword, |
| 418 const std::string& default_fetcher_response, |
| 419 const std::string& keyword_fetcher_response) { |
| 420 QueryForInput(text, false, prefer_keyword); |
| 421 if (!default_fetcher_response.empty()) { |
| 422 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( |
| 423 SearchProvider::kDefaultProviderURLFetcherID); |
| 424 ASSERT_TRUE(fetcher); |
| 425 fetcher->set_response_code(200); |
| 426 fetcher->SetResponseString(default_fetcher_response); |
| 427 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 428 } |
| 429 if (!keyword_fetcher_response.empty()) { |
| 430 net::TestURLFetcher* keyword_fetcher = test_factory_.GetFetcherByID( |
| 431 SearchProvider::kKeywordProviderURLFetcherID); |
| 432 ASSERT_TRUE(keyword_fetcher); |
| 433 keyword_fetcher->set_response_code(200); |
| 434 keyword_fetcher->SetResponseString(keyword_fetcher_response); |
| 435 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); |
| 436 } |
| 437 RunTillProviderDone(); |
| 438 } |
| 439 |
| 391 GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, | 440 GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, |
| 392 base::string16 term, | 441 base::string16 term, |
| 393 int visit_count) { | 442 int visit_count) { |
| 394 HistoryService* history = | 443 HistoryService* history = |
| 395 HistoryServiceFactory::GetForProfile(&profile_, | 444 HistoryServiceFactory::GetForProfile(&profile_, |
| 396 Profile::EXPLICIT_ACCESS); | 445 Profile::EXPLICIT_ACCESS); |
| 397 GURL search(t_url->url_ref().ReplaceSearchTerms( | 446 GURL search(t_url->url_ref().ReplaceSearchTerms( |
| 398 TemplateURLRef::SearchTermsArgs(term), | 447 TemplateURLRef::SearchTermsArgs(term), |
| 399 TemplateURLServiceFactory::GetForProfile( | 448 TemplateURLServiceFactory::GetForProfile( |
| 400 &profile_)->search_terms_data())); | 449 &profile_)->search_terms_data())); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 // Tell the SearchProvider the default suggest query is done. | 489 // Tell the SearchProvider the default suggest query is done. |
| 441 default_fetcher->set_response_code(200); | 490 default_fetcher->set_response_code(200); |
| 442 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); | 491 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); |
| 443 } | 492 } |
| 444 | 493 |
| 445 void SearchProviderTest::ForcedQueryTestHelper( | 494 void SearchProviderTest::ForcedQueryTestHelper( |
| 446 const std::string& input, | 495 const std::string& input, |
| 447 const std::string& json, | 496 const std::string& json, |
| 448 const std::string expected_matches[3], | 497 const std::string expected_matches[3], |
| 449 const std::string& error_description) { | 498 const std::string& error_description) { |
| 450 QueryForInput(ASCIIToUTF16(input), false, false); | 499 // Send the query twice in order to have a synchronous pass after the first |
| 451 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | 500 // response is received. This is necessary because SearchProvider doesn't |
| 452 SearchProvider::kDefaultProviderURLFetcherID); | 501 // allow an asynchronous response to change the default match. |
| 453 ASSERT_TRUE(fetcher); | 502 for (size_t i = 0; i < 2; ++i) { |
| 454 fetcher->set_response_code(200); | 503 QueryForInputAndWaitForFetcherResponses( |
| 455 fetcher->SetResponseString(json); | 504 ASCIIToUTF16(input), false, json, std::string()); |
| 456 fetcher->delegate()->OnURLFetchComplete(fetcher); | 505 } |
| 457 RunTillProviderDone(); | |
| 458 | 506 |
| 459 const ACMatches& matches = provider_->matches(); | 507 const ACMatches& matches = provider_->matches(); |
| 460 ASSERT_LE(matches.size(), 3u); | 508 ASSERT_LE(matches.size(), 3u); |
| 461 size_t i = 0; | 509 size_t i = 0; |
| 462 // Ensure that the returned matches equal the expectations. | 510 // Ensure that the returned matches equal the expectations. |
| 463 for (; i < matches.size(); ++i) { | 511 for (; i < matches.size(); ++i) { |
| 464 EXPECT_EQ(ASCIIToUTF16(expected_matches[i]), matches[i].contents) << | 512 EXPECT_EQ(ASCIIToUTF16(expected_matches[i]), matches[i].contents) << |
| 465 error_description; | 513 error_description; |
| 466 } | 514 } |
| 467 // Ensure that no expected matches are missing. | 515 // Ensure that no expected matches are missing. |
| 468 for (; i < 3u; ++i) { | 516 for (; i < 3u; ++i) { |
| 469 EXPECT_EQ(std::string(), expected_matches[i]) << | 517 EXPECT_EQ(std::string(), expected_matches[i]) << |
| 470 "Case #" << i << ": " << error_description; | 518 "Case #" << i << ": " << error_description; |
| 471 } | 519 } |
| 472 } | 520 } |
| 473 | 521 |
| 522 void SearchProviderTest::CheckMatches(const std::string& description, |
| 523 const size_t num_expected_matches, |
| 524 const ExpectedMatch expected_matches[], |
| 525 const ACMatches& matches) { |
| 526 ASSERT_FALSE(matches.empty()); |
| 527 ASSERT_LE(matches.size(), num_expected_matches); |
| 528 size_t i = 0; |
| 529 SCOPED_TRACE(description); |
| 530 // Ensure that the returned matches equal the expectations. |
| 531 for (; i < matches.size(); ++i) { |
| 532 SCOPED_TRACE(" Case # " + base::IntToString(i)); |
| 533 EXPECT_EQ(ASCIIToUTF16(expected_matches[i].contents), matches[i].contents); |
| 534 EXPECT_EQ(expected_matches[i].allowed_to_be_default_match, |
| 535 matches[i].allowed_to_be_default_match); |
| 536 } |
| 537 // Ensure that no expected matches are missing. |
| 538 for (; i < num_expected_matches; ++i) { |
| 539 SCOPED_TRACE(" Case # " + base::IntToString(i)); |
| 540 EXPECT_EQ(kNotApplicable, expected_matches[i].contents); |
| 541 } |
| 542 } |
| 543 |
| 474 void SearchProviderTest::ResetFieldTrialList() { | 544 void SearchProviderTest::ResetFieldTrialList() { |
| 475 // Destroy the existing FieldTrialList before creating a new one to avoid | 545 // Destroy the existing FieldTrialList before creating a new one to avoid |
| 476 // a DCHECK. | 546 // a DCHECK. |
| 477 field_trial_list_.reset(); | 547 field_trial_list_.reset(); |
| 478 field_trial_list_.reset(new base::FieldTrialList( | 548 field_trial_list_.reset(new base::FieldTrialList( |
| 479 new metrics::SHA1EntropyProvider("foo"))); | 549 new metrics::SHA1EntropyProvider("foo"))); |
| 480 variations::testing::ClearAllVariationParams(); | 550 variations::testing::ClearAllVariationParams(); |
| 481 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( | 551 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( |
| 482 "AutocompleteDynamicTrial_0", "DefaultGroup"); | 552 "AutocompleteDynamicTrial_0", "DefaultGroup"); |
| 483 trial->group(); | 553 trial->group(); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 ASCIIToUTF16("k a")) } }, | 1175 ASCIIToUTF16("k a")) } }, |
| 1106 }; | 1176 }; |
| 1107 | 1177 |
| 1108 RunTest(cases, arraysize(cases), false); | 1178 RunTest(cases, arraysize(cases), false); |
| 1109 } | 1179 } |
| 1110 | 1180 |
| 1111 // Verifies Navsuggest results don't set a TemplateURL, which Instant relies on. | 1181 // Verifies Navsuggest results don't set a TemplateURL, which Instant relies on. |
| 1112 // Also verifies that just the *first* navigational result is listed as a match | 1182 // Also verifies that just the *first* navigational result is listed as a match |
| 1113 // if suggested relevance scores were not sent. | 1183 // if suggested relevance scores were not sent. |
| 1114 TEST_F(SearchProviderTest, NavSuggestNoSuggestedRelevanceScores) { | 1184 TEST_F(SearchProviderTest, NavSuggestNoSuggestedRelevanceScores) { |
| 1115 QueryForInput(ASCIIToUTF16("a.c"), false, false); | 1185 QueryForInputAndWaitForFetcherResponses( |
| 1116 | 1186 ASCIIToUTF16("a.c"), false, |
| 1117 // Make sure the default providers suggest service was queried. | |
| 1118 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | |
| 1119 SearchProvider::kDefaultProviderURLFetcherID); | |
| 1120 ASSERT_TRUE(fetcher); | |
| 1121 | |
| 1122 // Tell the SearchProvider the suggest query is done. | |
| 1123 fetcher->set_response_code(200); | |
| 1124 fetcher->SetResponseString( | |
| 1125 "[\"a.c\",[\"a.com\", \"a.com/b\"],[\"a\", \"b\"],[]," | 1187 "[\"a.c\",[\"a.com\", \"a.com/b\"],[\"a\", \"b\"],[]," |
| 1126 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]"); | 1188 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
| 1127 fetcher->delegate()->OnURLFetchComplete(fetcher); | 1189 std::string()); |
| 1128 fetcher = NULL; | |
| 1129 | |
| 1130 // Run till the history results complete. | |
| 1131 RunTillProviderDone(); | |
| 1132 | 1190 |
| 1133 // Make sure the only match is 'a.com' and it doesn't have a template_url. | 1191 // Make sure the only match is 'a.com' and it doesn't have a template_url. |
| 1134 AutocompleteMatch nav_match; | 1192 AutocompleteMatch nav_match; |
| 1135 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); | 1193 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); |
| 1136 EXPECT_TRUE(nav_match.keyword.empty()); | 1194 EXPECT_TRUE(nav_match.keyword.empty()); |
| 1137 EXPECT_TRUE(nav_match.allowed_to_be_default_match); | 1195 EXPECT_FALSE(nav_match.allowed_to_be_default_match); |
| 1138 EXPECT_FALSE(FindMatchWithDestination(GURL("http://a.com/b"), &nav_match)); | 1196 EXPECT_FALSE(FindMatchWithDestination(GURL("http://a.com/b"), &nav_match)); |
| 1139 } | 1197 } |
| 1140 | 1198 |
| 1141 // Verifies that the most relevant suggest results are added properly. | 1199 // Verifies that the most relevant suggest results are added properly. |
| 1142 TEST_F(SearchProviderTest, SuggestRelevance) { | 1200 TEST_F(SearchProviderTest, SuggestRelevance) { |
| 1143 QueryForInput(ASCIIToUTF16("a"), false, false); | 1201 QueryForInputAndWaitForFetcherResponses( |
| 1144 | 1202 ASCIIToUTF16("a"), false, "[\"a\",[\"a1\", \"a2\", \"a3\", \"a4\"]]", |
| 1145 // Make sure the default provider's suggest service was queried. | 1203 std::string()); |
| 1146 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | |
| 1147 SearchProvider::kDefaultProviderURLFetcherID); | |
| 1148 ASSERT_TRUE(fetcher); | |
| 1149 | |
| 1150 // Tell the SearchProvider the suggest query is done. | |
| 1151 fetcher->set_response_code(200); | |
| 1152 fetcher->SetResponseString("[\"a\",[\"a1\", \"a2\", \"a3\", \"a4\"]]"); | |
| 1153 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 1154 fetcher = NULL; | |
| 1155 | |
| 1156 // Run till the history results complete. | |
| 1157 RunTillProviderDone(); | |
| 1158 | 1204 |
| 1159 // Check the expected verbatim and (first 3) suggestions' relative relevances. | 1205 // Check the expected verbatim and (first 3) suggestions' relative relevances. |
| 1160 AutocompleteMatch verbatim, match_a1, match_a2, match_a3, match_a4; | 1206 AutocompleteMatch verbatim, match_a1, match_a2, match_a3, match_a4; |
| 1161 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a"), &verbatim)); | 1207 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a"), &verbatim)); |
| 1162 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a1"), &match_a1)); | 1208 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a1"), &match_a1)); |
| 1163 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a2"), &match_a2)); | 1209 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a2"), &match_a2)); |
| 1164 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a3"), &match_a3)); | 1210 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a3"), &match_a3)); |
| 1165 EXPECT_FALSE(FindMatchWithContents(ASCIIToUTF16("a4"), &match_a4)); | 1211 EXPECT_FALSE(FindMatchWithContents(ASCIIToUTF16("a4"), &match_a4)); |
| 1166 EXPECT_GT(verbatim.relevance, match_a1.relevance); | 1212 EXPECT_GT(verbatim.relevance, match_a1.relevance); |
| 1167 EXPECT_GT(match_a1.relevance, match_a2.relevance); | 1213 EXPECT_GT(match_a1.relevance, match_a2.relevance); |
| 1168 EXPECT_GT(match_a2.relevance, match_a3.relevance); | 1214 EXPECT_GT(match_a2.relevance, match_a3.relevance); |
| 1169 EXPECT_TRUE(verbatim.allowed_to_be_default_match); | 1215 EXPECT_TRUE(verbatim.allowed_to_be_default_match); |
| 1170 EXPECT_TRUE(match_a1.allowed_to_be_default_match); | 1216 EXPECT_FALSE(match_a1.allowed_to_be_default_match); |
| 1171 EXPECT_TRUE(match_a2.allowed_to_be_default_match); | 1217 EXPECT_FALSE(match_a2.allowed_to_be_default_match); |
| 1172 EXPECT_TRUE(match_a3.allowed_to_be_default_match); | 1218 EXPECT_FALSE(match_a3.allowed_to_be_default_match); |
| 1173 } | 1219 } |
| 1174 | 1220 |
| 1175 // Verifies that the default provider abandons suggested relevance scores | 1221 // Verifies that the default provider abandons suggested relevance scores |
| 1176 // when in keyword mode. This should happen regardless of whether the | 1222 // when in keyword mode. This should happen regardless of whether the |
| 1177 // keyword provider returns suggested relevance scores. | 1223 // keyword provider returns suggested relevance scores. |
| 1178 TEST_F(SearchProviderTest, DefaultProviderNoSuggestRelevanceInKeywordMode) { | 1224 TEST_F(SearchProviderTest, DefaultProviderNoSuggestRelevanceInKeywordMode) { |
| 1179 struct { | 1225 struct { |
| 1180 const std::string default_provider_json; | 1226 const std::string default_provider_json; |
| 1181 const std::string keyword_provider_json; | 1227 const std::string keyword_provider_json; |
| 1182 const std::string matches[5]; | 1228 const std::string matches[5]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1194 { "[\"k a\",[\"k adefault-query\", \"adefault.com\"],[],[]," | 1240 { "[\"k a\",[\"k adefault-query\", \"adefault.com\"],[],[]," |
| 1195 "{\"google:verbatimrelevance\":9700," | 1241 "{\"google:verbatimrelevance\":9700," |
| 1196 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," | 1242 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," |
| 1197 "\"google:suggestrelevance\":[9900, 9800]}]", | 1243 "\"google:suggestrelevance\":[9900, 9800]}]", |
| 1198 "[\"a\",[\"akeyword-query\"],[],[],{\"google:suggesttype\":[\"QUERY\"]," | 1244 "[\"a\",[\"akeyword-query\"],[],[],{\"google:suggesttype\":[\"QUERY\"]," |
| 1199 "\"google:verbatimrelevance\":9500," | 1245 "\"google:verbatimrelevance\":9500," |
| 1200 "\"google:suggestrelevance\":[9600]}]", | 1246 "\"google:suggestrelevance\":[9600]}]", |
| 1201 { "akeyword-query", "a", "k a", "adefault.com", "k adefault-query" } } | 1247 { "akeyword-query", "a", "k a", "adefault.com", "k adefault-query" } } |
| 1202 }; | 1248 }; |
| 1203 | 1249 |
| 1204 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 1250 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 1205 QueryForInput(ASCIIToUTF16("k a"), false, true); | 1251 // Send the query twice in order to have a synchronous pass after the first |
| 1206 net::TestURLFetcher* default_fetcher = | 1252 // response is received. This is necessary because SearchProvider doesn't |
| 1207 test_factory_.GetFetcherByID( | 1253 // allow an asynchronous response to change the default match. |
| 1208 SearchProvider::kDefaultProviderURLFetcherID); | 1254 for (size_t j = 0; j < 2; ++j) { |
| 1209 ASSERT_TRUE(default_fetcher); | 1255 QueryForInputAndWaitForFetcherResponses( |
| 1210 default_fetcher->set_response_code(200); | 1256 ASCIIToUTF16("k a"), true, cases[i].default_provider_json, |
| 1211 default_fetcher->SetResponseString(cases[i].default_provider_json); | 1257 cases[i].keyword_provider_json); |
| 1212 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); | 1258 } |
| 1213 net::TestURLFetcher* keyword_fetcher = | |
| 1214 test_factory_.GetFetcherByID( | |
| 1215 SearchProvider::kKeywordProviderURLFetcherID); | |
| 1216 ASSERT_TRUE(keyword_fetcher); | |
| 1217 keyword_fetcher->set_response_code(200); | |
| 1218 keyword_fetcher->SetResponseString(cases[i].keyword_provider_json); | |
| 1219 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); | |
| 1220 RunTillProviderDone(); | |
| 1221 | 1259 |
| 1222 const std::string description = "for input with default_provider_json=" + | 1260 SCOPED_TRACE( |
| 1261 "for input with default_provider_json=" + |
| 1223 cases[i].default_provider_json + " and keyword_provider_json=" + | 1262 cases[i].default_provider_json + " and keyword_provider_json=" + |
| 1224 cases[i].keyword_provider_json; | 1263 cases[i].keyword_provider_json); |
| 1225 const ACMatches& matches = provider_->matches(); | 1264 const ACMatches& matches = provider_->matches(); |
| 1226 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 1265 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
| 1227 size_t j = 0; | 1266 size_t j = 0; |
| 1228 // Ensure that the returned matches equal the expectations. | 1267 // Ensure that the returned matches equal the expectations. |
| 1229 for (; j < matches.size(); ++j) { | 1268 for (; j < matches.size(); ++j) |
| 1230 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j]), matches[j].contents) << | 1269 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j]), matches[j].contents); |
| 1231 description; | |
| 1232 } | |
| 1233 // Ensure that no expected matches are missing. | 1270 // Ensure that no expected matches are missing. |
| 1234 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) | 1271 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) |
| 1235 EXPECT_EQ(std::string(), cases[i].matches[j]) << description; | 1272 EXPECT_EQ(std::string(), cases[i].matches[j]); |
| 1236 } | 1273 } |
| 1237 } | 1274 } |
| 1238 | 1275 |
| 1239 // Verifies that suggest results with relevance scores are added | 1276 // Verifies that suggest results with relevance scores are added |
| 1240 // properly when using the default fetcher. When adding a new test | 1277 // properly when using the default fetcher. When adding a new test |
| 1241 // case to this test, please consider adding it to the tests in | 1278 // case to this test, please consider adding it to the tests in |
| 1242 // KeywordFetcherSuggestRelevance below. | 1279 // KeywordFetcherSuggestRelevance below. |
| 1243 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { | 1280 TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { |
| 1244 struct DefaultFetcherMatch { | |
| 1245 std::string contents; | |
| 1246 bool allowed_to_be_default_match; | |
| 1247 }; | |
| 1248 const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; | |
| 1249 struct { | 1281 struct { |
| 1250 const std::string json; | 1282 const std::string json; |
| 1251 const DefaultFetcherMatch matches[6]; | 1283 const ExpectedMatch matches[6]; |
| 1252 const std::string inline_autocompletion; | 1284 const std::string inline_autocompletion; |
| 1253 } cases[] = { | 1285 } cases[] = { |
| 1254 // Ensure that suggestrelevance scores reorder matches. | 1286 // Ensure that suggestrelevance scores reorder matches. |
| 1255 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", | 1287 { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
| 1256 { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch, kEmptyMatch, | 1288 { { "a", true }, { "c", false }, { "b", false }, kEmptyExpectedMatch, |
| 1257 kEmptyMatch }, | 1289 kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1258 std::string() }, | 1290 std::string() }, |
| 1259 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 1291 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
| 1260 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1292 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1261 "\"google:suggestrelevance\":[1, 2]}]", | 1293 "\"google:suggestrelevance\":[1, 2]}]", |
| 1262 { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch, | 1294 { { "a", true }, { "c.com", false }, { "b.com", false }, |
| 1263 kEmptyMatch, kEmptyMatch }, | 1295 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1264 std::string() }, | 1296 std::string() }, |
| 1265 | 1297 |
| 1266 // Without suggested relevance scores, we should only allow one | 1298 // Without suggested relevance scores, we should only allow one |
| 1267 // navsuggest result to be be displayed. | 1299 // navsuggest result to be be displayed. |
| 1268 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," | 1300 { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," |
| 1269 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", | 1301 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", |
| 1270 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, | 1302 { { "a", true }, { "b.com", false }, kEmptyExpectedMatch, |
| 1271 kEmptyMatch, kEmptyMatch }, | 1303 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1272 std::string() }, | 1304 std::string() }, |
| 1273 | 1305 |
| 1274 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 1306 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
| 1275 // Negative values will have no effect; the calculated value will be used. | 1307 // Negative values will have no effect; the calculated value will be used. |
| 1276 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 1308 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
| 1277 "\"google:suggestrelevance\":[9998]}]", | 1309 "\"google:suggestrelevance\":[9998]}]", |
| 1278 { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1310 { { "a", true}, { "a1", false }, kEmptyExpectedMatch, |
| 1279 kEmptyMatch }, | 1311 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1280 std::string() }, | 1312 std::string() }, |
| 1281 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 1313 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
| 1282 "\"google:suggestrelevance\":[9999]}]", | 1314 "\"google:suggestrelevance\":[9999]}]", |
| 1283 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1315 { { "a1", true }, { "a", true }, kEmptyExpectedMatch, |
| 1284 kEmptyMatch }, | 1316 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1285 "1" }, | 1317 "1" }, |
| 1286 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," | 1318 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," |
| 1287 "\"google:suggestrelevance\":[9999]}]", | 1319 "\"google:suggestrelevance\":[9999]}]", |
| 1288 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1320 { { "a1", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, |
| 1289 kEmptyMatch }, | 1321 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1290 "1" }, | 1322 "1" }, |
| 1291 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," | 1323 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," |
| 1292 "\"google:suggestrelevance\":[9999]}]", | 1324 "\"google:suggestrelevance\":[9999]}]", |
| 1293 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1325 { { "a1", true }, { "a", true }, kEmptyExpectedMatch, |
| 1294 kEmptyMatch }, | 1326 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1295 "1" }, | 1327 "1" }, |
| 1296 { "[\"a\",[\"http://a.com\"],[],[]," | 1328 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1297 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1329 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1298 "\"google:verbatimrelevance\":9999," | 1330 "\"google:verbatimrelevance\":9999," |
| 1299 "\"google:suggestrelevance\":[9998]}]", | 1331 "\"google:suggestrelevance\":[9998]}]", |
| 1300 { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1332 { { "a", true }, { "a.com", false }, kEmptyExpectedMatch, |
| 1301 kEmptyMatch }, | 1333 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1302 std::string() }, | 1334 std::string() }, |
| 1303 { "[\"a\",[\"http://a.com\"],[],[]," | 1335 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1304 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1336 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1305 "\"google:verbatimrelevance\":9998," | 1337 "\"google:verbatimrelevance\":9998," |
| 1306 "\"google:suggestrelevance\":[9999]}]", | 1338 "\"google:suggestrelevance\":[9999]}]", |
| 1307 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1339 { { "a.com", true }, { "a", true }, kEmptyExpectedMatch, |
| 1308 kEmptyMatch }, | 1340 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1309 ".com" }, | 1341 ".com" }, |
| 1310 { "[\"a\",[\"http://a.com\"],[],[]," | 1342 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1311 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1343 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1312 "\"google:verbatimrelevance\":0," | 1344 "\"google:verbatimrelevance\":0," |
| 1313 "\"google:suggestrelevance\":[9999]}]", | 1345 "\"google:suggestrelevance\":[9999]}]", |
| 1314 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1346 { { "a.com", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, |
| 1315 kEmptyMatch }, | 1347 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1316 ".com" }, | 1348 ".com" }, |
| 1317 { "[\"a\",[\"http://a.com\"],[],[]," | 1349 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1318 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1350 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1319 "\"google:verbatimrelevance\":-1," | 1351 "\"google:verbatimrelevance\":-1," |
| 1320 "\"google:suggestrelevance\":[9999]}]", | 1352 "\"google:suggestrelevance\":[9999]}]", |
| 1321 { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1353 { { "a.com", true }, { "a", true }, kEmptyExpectedMatch, |
| 1322 kEmptyMatch }, | 1354 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1323 ".com" }, | 1355 ".com" }, |
| 1324 | 1356 |
| 1325 // Ensure that both types of relevance scores reorder matches together. | 1357 // Ensure that both types of relevance scores reorder matches together. |
| 1326 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 1358 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
| 1327 "\"google:verbatimrelevance\":9998}]", | 1359 "\"google:verbatimrelevance\":9998}]", |
| 1328 { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, | 1360 { { "a1", true }, { "a", true }, { "a2", false }, kEmptyExpectedMatch, |
| 1329 kEmptyMatch }, | 1361 kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1330 "1" }, | 1362 "1" }, |
| 1331 | 1363 |
| 1332 // Allow non-inlineable matches to be the highest-scoring match but, | 1364 // Check that an inlineable result appears first regardless of its score. |
| 1333 // if the result set lacks a single inlineable result, abandon suggested | 1365 // Also, if the result set lacks a single inlineable result, abandon the |
| 1334 // relevance scores entirely. | 1366 // request to suppress verbatim (verbatim_relevance=0), which will then |
| 1367 // cause verbatim to appear (first). |
| 1335 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 1368 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
| 1336 { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1369 { { "a", true }, { "b", false }, kEmptyExpectedMatch, |
| 1337 kEmptyMatch }, | 1370 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1338 std::string() }, | 1371 std::string() }, |
| 1339 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | 1372 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
| 1340 "\"google:verbatimrelevance\":0}]", | 1373 "\"google:verbatimrelevance\":0}]", |
| 1341 { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1374 { { "a", true }, { "b", false }, kEmptyExpectedMatch, |
| 1342 kEmptyMatch }, | 1375 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1343 std::string() }, | 1376 std::string() }, |
| 1344 { "[\"a\",[\"http://b.com\"],[],[]," | 1377 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1345 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1378 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1346 "\"google:suggestrelevance\":[9999]}]", | 1379 "\"google:suggestrelevance\":[9999]}]", |
| 1347 { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch, | 1380 { { "a", true }, { "b.com", false }, kEmptyExpectedMatch, |
| 1348 kEmptyMatch, kEmptyMatch }, | 1381 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1349 std::string() }, | 1382 std::string() }, |
| 1350 { "[\"a\",[\"http://b.com\"],[],[]," | 1383 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1351 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1384 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1352 "\"google:suggestrelevance\":[9999]," | 1385 "\"google:suggestrelevance\":[9999]," |
| 1353 "\"google:verbatimrelevance\":0}]", | 1386 "\"google:verbatimrelevance\":0}]", |
| 1354 { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, | 1387 { { "a", true }, { "b.com", false }, kEmptyExpectedMatch, |
| 1355 kEmptyMatch, kEmptyMatch }, | 1388 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1356 std::string() }, | 1389 std::string() }, |
| 1357 | 1390 |
| 1358 // Allow low-scoring matches. | 1391 // Allow low-scoring matches. |
| 1359 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 1392 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
| 1360 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1393 { { "a1", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, |
| 1361 kEmptyMatch }, | 1394 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1362 "1" }, | 1395 "1" }, |
| 1363 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", | 1396 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":10}]", |
| 1364 { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1397 { { "a1", true }, { "a", true }, kEmptyExpectedMatch, |
| 1365 kEmptyMatch }, | 1398 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1366 "1" }, | 1399 "1" }, |
| 1367 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," | 1400 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[10]," |
| 1368 "\"google:verbatimrelevance\":0}]", | 1401 "\"google:verbatimrelevance\":0}]", |
| 1369 { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1402 { { "a1", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, |
| 1370 kEmptyMatch }, | 1403 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1371 "1" }, | 1404 "1" }, |
| 1372 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," | 1405 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10, 20]," |
| 1373 "\"google:verbatimrelevance\":0}]", | 1406 "\"google:verbatimrelevance\":0}]", |
| 1374 { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1407 { { "a2", true }, { "a1", false }, kEmptyExpectedMatch, |
| 1375 kEmptyMatch }, | 1408 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1376 "2" }, | 1409 "2" }, |
| 1377 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," | 1410 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10, 30]," |
| 1378 "\"google:verbatimrelevance\":2}]", | 1411 "\"google:verbatimrelevance\":20}]", |
| 1379 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, | 1412 { { "a2", true }, { "a", true }, { "a1", false }, kEmptyExpectedMatch, |
| 1380 kEmptyMatch }, | 1413 kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1381 "2" }, | 1414 "2" }, |
| 1382 { "[\"a\",[\"http://a.com\"],[],[]," | 1415 { "[\"a\",[\"http://a.com\"],[],[]," |
| 1383 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1416 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1384 "\"google:suggestrelevance\":[1]," | 1417 "\"google:suggestrelevance\":[10]," |
| 1385 "\"google:verbatimrelevance\":0}]", | 1418 "\"google:verbatimrelevance\":0}]", |
| 1386 { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1419 { { "a.com", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, |
| 1387 kEmptyMatch }, | 1420 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1388 ".com" }, | 1421 ".com" }, |
| 1389 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1422 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1390 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1423 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1391 "\"google:suggestrelevance\":[1, 2]," | 1424 "\"google:suggestrelevance\":[10, 20]," |
| 1392 "\"google:verbatimrelevance\":0}]", | 1425 "\"google:verbatimrelevance\":0}]", |
| 1393 { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, | 1426 { { "a2.com", true }, { "a1.com", false }, kEmptyExpectedMatch, |
| 1394 kEmptyMatch, kEmptyMatch }, | 1427 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1395 "2.com" }, | 1428 "2.com" }, |
| 1396 | 1429 |
| 1397 // Ensure that all suggestions are considered, regardless of order. | 1430 // Ensure that all suggestions are considered, regardless of order. |
| 1398 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 1431 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
| 1399 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1432 "{\"google:suggestrelevance\":[10, 20, 30, 40, 50, 60, 70]}]", |
| 1400 { { "a", true }, { "h", false }, { "g", false }, { "f", false }, | 1433 { { "a", true }, { "h", false }, { "g", false }, { "f", false }, |
| 1401 { "e", false }, { "d", false } }, | 1434 { "e", false }, { "d", false } }, |
| 1402 std::string() }, | 1435 std::string() }, |
| 1403 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 1436 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
| 1404 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 1437 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
| 1405 "\"http://h.com\"],[],[]," | 1438 "\"http://h.com\"],[],[]," |
| 1406 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 1439 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
| 1407 "\"NAVIGATION\", \"NAVIGATION\"," | 1440 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1408 "\"NAVIGATION\", \"NAVIGATION\"," | 1441 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1409 "\"NAVIGATION\"]," | 1442 "\"NAVIGATION\"]," |
| 1410 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1443 "\"google:suggestrelevance\":[10, 20, 30, 40, 50, 60, 70]}]", |
| 1411 { { "a", true }, { "h.com", false }, { "g.com", false }, | 1444 { { "a", true }, { "h.com", false }, { "g.com", false }, |
| 1412 { "f.com", false }, { "e.com", false }, { "d.com", false } }, | 1445 { "f.com", false }, { "e.com", false }, { "d.com", false } }, |
| 1413 std::string() }, | 1446 std::string() }, |
| 1414 | 1447 |
| 1415 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 1448 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
| 1416 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", | 1449 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10]}]", |
| 1417 { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, | 1450 { { "a", true }, { "a1", false }, { "a2", false }, kEmptyExpectedMatch, |
| 1418 kEmptyMatch }, | 1451 kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1419 std::string() }, | 1452 std::string() }, |
| 1420 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", | 1453 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 10]}]", |
| 1421 { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1454 { { "a", true }, { "a1", false }, kEmptyExpectedMatch, |
| 1422 kEmptyMatch }, | 1455 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1423 std::string() }, | 1456 std::string() }, |
| 1424 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1457 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1425 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1458 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1426 "\"google:suggestrelevance\":[1]}]", | 1459 "\"google:suggestrelevance\":[10]}]", |
| 1427 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, | 1460 { { "a", true }, { "a1.com", false }, kEmptyExpectedMatch, |
| 1428 kEmptyMatch, kEmptyMatch }, | 1461 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1429 std::string() }, | 1462 std::string() }, |
| 1430 { "[\"a\",[\"http://a1.com\"],[],[]," | 1463 { "[\"a\",[\"http://a1.com\"],[],[]," |
| 1431 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1464 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1432 "\"google:suggestrelevance\":[9999, 1]}]", | 1465 "\"google:suggestrelevance\":[9999, 10]}]", |
| 1433 { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, | 1466 { { "a", true }, { "a1.com", false }, kEmptyExpectedMatch, |
| 1434 kEmptyMatch, kEmptyMatch }, | 1467 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1435 std::string() }, | 1468 std::string() }, |
| 1436 | 1469 |
| 1437 // Ensure that all 'verbatim' results are merged with their maximum score. | 1470 // Ensure that all 'verbatim' results are merged with their maximum score. |
| 1438 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1471 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1439 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1472 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
| 1440 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, | 1473 { { "a2", true }, { "a", true }, { "a1", false }, kEmptyExpectedMatch, |
| 1441 kEmptyMatch }, | 1474 kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1442 "2" }, | 1475 "2" }, |
| 1443 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1476 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1444 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 1477 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
| 1445 "\"google:verbatimrelevance\":0}]", | 1478 "\"google:verbatimrelevance\":0}]", |
| 1446 { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, | 1479 { { "a2", true }, { "a", true }, { "a1", false }, kEmptyExpectedMatch, |
| 1447 kEmptyMatch }, | 1480 kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1448 "2" }, | 1481 "2" }, |
| 1449 | 1482 |
| 1450 // Ensure that verbatim is always generated without other suggestions. | 1483 // Ensure that verbatim is always generated without other suggestions. |
| 1451 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). | 1484 // TODO(msw): Ensure verbatimrelevance is respected (except suppression). |
| 1452 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 1485 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
| 1453 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1486 { { "a", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, |
| 1454 kEmptyMatch }, | 1487 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1455 std::string() }, | 1488 std::string() }, |
| 1456 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 1489 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
| 1457 { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, | 1490 { { "a", true }, kEmptyExpectedMatch, kEmptyExpectedMatch, |
| 1458 kEmptyMatch }, | 1491 kEmptyExpectedMatch, kEmptyExpectedMatch, kEmptyExpectedMatch }, |
| 1459 std::string() }, | 1492 std::string() }, |
| 1460 }; | 1493 }; |
| 1461 | 1494 |
| 1462 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 1495 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 1463 QueryForInput(ASCIIToUTF16("a"), false, false); | 1496 // Send the query twice in order to have a synchronous pass after the first |
| 1464 net::TestURLFetcher* fetcher = | 1497 // response is received. This is necessary because SearchProvider doesn't |
| 1465 test_factory_.GetFetcherByID( | 1498 // allow an asynchronous response to change the default match. |
| 1466 SearchProvider::kDefaultProviderURLFetcherID); | 1499 for (size_t j = 0; j < 2; ++j) { |
| 1467 ASSERT_TRUE(fetcher); | 1500 QueryForInputAndWaitForFetcherResponses( |
| 1468 fetcher->set_response_code(200); | 1501 ASCIIToUTF16("a"), false, cases[i].json, std::string()); |
| 1469 fetcher->SetResponseString(cases[i].json); | 1502 } |
| 1470 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 1471 RunTillProviderDone(); | |
| 1472 | 1503 |
| 1473 const std::string description = "for input with json=" + cases[i].json; | 1504 const std::string description = "for input with json=" + cases[i].json; |
| 1474 const ACMatches& matches = provider_->matches(); | 1505 CheckMatches(description, ARRAYSIZE_UNSAFE(cases[i].matches), |
| 1475 ASSERT_FALSE(matches.empty()); | 1506 cases[i].matches, provider_->matches()); |
| 1476 // Find the first match that's allowed to be the default match and check | |
| 1477 // its inline_autocompletion. | |
| 1478 ACMatches::const_iterator it = FindDefaultMatch(matches); | |
| 1479 ASSERT_NE(matches.end(), it); | |
| 1480 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | |
| 1481 it->inline_autocompletion) << description; | |
| 1482 | |
| 1483 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | |
| 1484 size_t j = 0; | |
| 1485 // Ensure that the returned matches equal the expectations. | |
| 1486 for (; j < matches.size(); ++j) { | |
| 1487 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), | |
| 1488 matches[j].contents) << description; | |
| 1489 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, | |
| 1490 matches[j].allowed_to_be_default_match) << description; | |
| 1491 } | |
| 1492 // Ensure that no expected matches are missing. | |
| 1493 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) | |
| 1494 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << | |
| 1495 "Case # " << i << " " << description; | |
| 1496 } | 1507 } |
| 1497 } | 1508 } |
| 1498 | 1509 |
| 1499 // Verifies that suggest results with relevance scores are added | 1510 // Verifies that suggest results with relevance scores are added |
| 1500 // properly when using the keyword fetcher. This is similar to the | 1511 // properly when using the keyword fetcher. This is similar to the |
| 1501 // test DefaultFetcherSuggestRelevance above but this uses inputs that | 1512 // test DefaultFetcherSuggestRelevance above but this uses inputs that |
| 1502 // trigger keyword suggestions (i.e., "k a" rather than "a") and has | 1513 // trigger keyword suggestions (i.e., "k a" rather than "a") and has |
| 1503 // different expectations (because now the results are a mix of | 1514 // different expectations (because now the results are a mix of |
| 1504 // keyword suggestions and default provider suggestions). When a new | 1515 // keyword suggestions and default provider suggestions). When a new |
| 1505 // test is added to this TEST_F, please consider if it would be | 1516 // test is added to this TEST_F, please consider if it would be |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 { "b.com", false, false }, | 1562 { "b.com", false, false }, |
| 1552 { "k a", false, false }, | 1563 { "k a", false, false }, |
| 1553 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1564 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1554 std::string() }, | 1565 std::string() }, |
| 1555 | 1566 |
| 1556 // Ensure that verbatimrelevance scores reorder or suppress verbatim. | 1567 // Ensure that verbatimrelevance scores reorder or suppress verbatim. |
| 1557 // Negative values will have no effect; the calculated value will be used. | 1568 // Negative values will have no effect; the calculated value will be used. |
| 1558 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," | 1569 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," |
| 1559 "\"google:suggestrelevance\":[9998]}]", | 1570 "\"google:suggestrelevance\":[9998]}]", |
| 1560 { { "a", true, true }, | 1571 { { "a", true, true }, |
| 1561 { "a1", true, true }, | 1572 { "a1", true, false }, |
| 1562 { "k a", false, false }, | 1573 { "k a", false, false }, |
| 1563 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1574 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1564 std::string() }, | 1575 std::string() }, |
| 1565 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," | 1576 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," |
| 1566 "\"google:suggestrelevance\":[9999]}]", | 1577 "\"google:suggestrelevance\":[9999]}]", |
| 1567 { { "a1", true, true }, | 1578 { { "a1", true, true }, |
| 1568 { "a", true, true }, | 1579 { "a", true, true }, |
| 1569 { "k a", false, false }, | 1580 { "k a", false, false }, |
| 1570 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1581 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1571 "1" }, | 1582 "1" }, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1590 { "a.com", false, false }, | 1601 { "a.com", false, false }, |
| 1591 { "k a", false, false }, | 1602 { "k a", false, false }, |
| 1592 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1603 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1593 std::string() }, | 1604 std::string() }, |
| 1594 | 1605 |
| 1595 // Ensure that both types of relevance scores reorder matches together. | 1606 // Ensure that both types of relevance scores reorder matches together. |
| 1596 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," | 1607 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," |
| 1597 "\"google:verbatimrelevance\":9998}]", | 1608 "\"google:verbatimrelevance\":9998}]", |
| 1598 { { "a1", true, true }, | 1609 { { "a1", true, true }, |
| 1599 { "a", true, true }, | 1610 { "a", true, true }, |
| 1600 { "a2", true, true }, | 1611 { "a2", true, false }, |
| 1601 { "k a", false, false }, | 1612 { "k a", false, false }, |
| 1602 kEmptyMatch, kEmptyMatch }, | 1613 kEmptyMatch, kEmptyMatch }, |
| 1603 "1" }, | 1614 "1" }, |
| 1604 | 1615 |
| 1605 // Check that non-inlinable matches may be ranked as the highest result | 1616 // Check that an inlineable match appears first regardless of its score. |
| 1606 // if there is at least one inlineable match. | |
| 1607 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", | 1617 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", |
| 1608 { { "b", true, false }, | 1618 { { "a", true, true }, |
| 1609 { "a", true, true }, | 1619 { "b", true, false }, |
| 1610 { "k a", false, false }, | 1620 { "k a", false, false }, |
| 1611 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1621 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1612 std::string() }, | 1622 std::string() }, |
| 1613 { "[\"a\",[\"http://b.com\"],[],[]," | 1623 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1614 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1624 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1615 "\"google:suggestrelevance\":[9999]}]", | 1625 "\"google:suggestrelevance\":[9999]}]", |
| 1616 { { "b.com", false, false }, | 1626 { { "a", true, true }, |
| 1617 { "a", true, true }, | 1627 { "b.com", false, false }, |
| 1618 { "k a", false, false }, | 1628 { "k a", false, false }, |
| 1619 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1629 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1620 std::string() }, | 1630 std::string() }, |
| 1621 // On the other hand, if there is no inlineable match, restore | 1631 // If there is no inlineable match, restore the keyword verbatim score. |
| 1622 // the keyword verbatim score. | 1632 // The keyword verbatim match will then appear first. |
| 1623 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," | 1633 { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," |
| 1624 "\"google:verbatimrelevance\":0}]", | 1634 "\"google:verbatimrelevance\":0}]", |
| 1625 { { "b", true, false }, | 1635 { { "a", true, true }, |
| 1626 { "a", true, true }, | 1636 { "b", true, false }, |
| 1627 { "k a", false, false }, | 1637 { "k a", false, false }, |
| 1628 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1638 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1629 std::string() }, | 1639 std::string() }, |
| 1630 { "[\"a\",[\"http://b.com\"],[],[]," | 1640 { "[\"a\",[\"http://b.com\"],[],[]," |
| 1631 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1641 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1632 "\"google:suggestrelevance\":[9999]," | 1642 "\"google:suggestrelevance\":[9999]," |
| 1633 "\"google:verbatimrelevance\":0}]", | 1643 "\"google:verbatimrelevance\":0}]", |
| 1634 { { "b.com", false, false }, | 1644 { { "a", true, true }, |
| 1635 { "a", true, true }, | 1645 { "b.com", false, false }, |
| 1636 { "k a", false, false }, | 1646 { "k a", false, false }, |
| 1637 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1647 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1638 std::string() }, | 1648 std::string() }, |
| 1639 | 1649 |
| 1640 // The top result does not have to score as highly as calculated | 1650 // The top result does not have to score as highly as calculated |
| 1641 // verbatim. i.e., there are no minimum score restrictions in | 1651 // verbatim. i.e., there are no minimum score restrictions in |
| 1642 // this provider. | 1652 // this provider. |
| 1643 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", | 1653 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", |
| 1644 { { "a1", true, true }, | 1654 { { "a1", true, true }, |
| 1645 { "k a", false, false }, | 1655 { "k a", false, false }, |
| 1646 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1656 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1647 "1" }, | 1657 "1" }, |
| 1648 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", | 1658 { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":10}]", |
| 1649 { { "a1", true, true }, | 1659 { { "a1", true, true }, |
| 1650 { "k a", false, false }, | 1660 { "k a", false, false }, |
| 1651 { "a", true, true }, | 1661 { "a", true, true }, |
| 1652 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1662 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1653 "1" }, | 1663 "1" }, |
| 1654 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," | 1664 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[10]," |
| 1655 "\"google:verbatimrelevance\":0}]", | 1665 "\"google:verbatimrelevance\":0}]", |
| 1656 { { "k a", false, false }, | 1666 { { "a1", true, true }, |
| 1657 { "a1", true, true }, | 1667 { "k a", false, false }, |
| 1658 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1668 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1659 "1" }, | 1669 "1" }, |
| 1660 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," | 1670 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10, 20]," |
| 1661 "\"google:verbatimrelevance\":0}]", | 1671 "\"google:verbatimrelevance\":0}]", |
| 1662 { | 1672 { { "a2", true, true }, |
| 1663 { "k a", false, false }, | 1673 { "k a", false, false }, |
| 1664 { "a2", true, true }, | 1674 { "a1", true, false }, |
| 1665 { "a1", true, true }, | |
| 1666 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1675 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1667 "2" }, | 1676 "2" }, |
| 1668 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," | 1677 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[10, 30]," |
| 1669 "\"google:verbatimrelevance\":2}]", | 1678 "\"google:verbatimrelevance\":20}]", |
| 1670 { { "k a", false, false }, | 1679 { { "a2", true, true }, |
| 1671 { "a2", true, true }, | 1680 { "k a", false, false }, |
| 1672 { "a", true, true }, | 1681 { "a", true, true }, |
| 1673 { "a1", true, true }, | 1682 { "a1", true, false }, |
| 1674 kEmptyMatch, kEmptyMatch }, | 1683 kEmptyMatch, kEmptyMatch }, |
| 1675 "2" }, | 1684 "2" }, |
| 1676 | 1685 |
| 1677 // Ensure that all suggestions are considered, regardless of order. | 1686 // Ensure that all suggestions are considered, regardless of order. |
| 1678 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," | 1687 { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," |
| 1679 "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1688 "{\"google:suggestrelevance\":[10, 20, 30, 40, 50, 60, 70]}]", |
| 1680 { { "a", true, true }, | 1689 { { "a", true, true }, |
| 1681 { "k a", false, false }, | 1690 { "k a", false, false }, |
| 1682 { "h", true, false }, | 1691 { "h", true, false }, |
| 1683 { "g", true, false }, | 1692 { "g", true, false }, |
| 1684 { "f", true, false }, | 1693 { "f", true, false }, |
| 1685 { "e", true, false } }, | 1694 { "e", true, false } }, |
| 1686 std::string() }, | 1695 std::string() }, |
| 1687 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," | 1696 { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," |
| 1688 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," | 1697 "\"http://e.com\", \"http://f.com\", \"http://g.com\"," |
| 1689 "\"http://h.com\"],[],[]," | 1698 "\"http://h.com\"],[],[]," |
| 1690 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," | 1699 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"," |
| 1691 "\"NAVIGATION\", \"NAVIGATION\"," | 1700 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1692 "\"NAVIGATION\", \"NAVIGATION\"," | 1701 "\"NAVIGATION\", \"NAVIGATION\"," |
| 1693 "\"NAVIGATION\"]," | 1702 "\"NAVIGATION\"]," |
| 1694 "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", | 1703 "\"google:suggestrelevance\":[10, 20, 30, 40, 50, 60, 70]}]", |
| 1695 { { "a", true, true }, | 1704 { { "a", true, true }, |
| 1696 { "k a", false, false }, | 1705 { "k a", false, false }, |
| 1697 { "h.com", false, false }, | 1706 { "h.com", false, false }, |
| 1698 { "g.com", false, false }, | 1707 { "g.com", false, false }, |
| 1699 { "f.com", false, false }, | 1708 { "f.com", false, false }, |
| 1700 { "e.com", false, false } }, | 1709 { "e.com", false, false } }, |
| 1701 std::string() }, | 1710 std::string() }, |
| 1702 | 1711 |
| 1703 // Ensure that incorrectly sized suggestion relevance lists are ignored. | 1712 // Ensure that incorrectly sized suggestion relevance lists are ignored. |
| 1704 // Note that keyword suggestions by default (not in suggested relevance | 1713 // Note that keyword suggestions by default (not in suggested relevance |
| 1705 // mode) score more highly than the default verbatim. | 1714 // mode) score more highly than the default verbatim. |
| 1706 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", | 1715 { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", |
| 1707 { { "a", true, true }, | 1716 { { "a", true, true }, |
| 1708 { "a1", true, true }, | 1717 { "a1", true, false }, |
| 1709 { "a2", true, true }, | 1718 { "a2", true, false }, |
| 1710 { "k a", false, false }, | 1719 { "k a", false, false }, |
| 1711 kEmptyMatch, kEmptyMatch }, | 1720 kEmptyMatch, kEmptyMatch }, |
| 1712 std::string() }, | 1721 std::string() }, |
| 1713 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", | 1722 { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", |
| 1714 { { "a", true, true }, | 1723 { { "a", true, true }, |
| 1715 { "a1", true, true }, | 1724 { "a1", true, false }, |
| 1716 { "k a", false, false }, | 1725 { "k a", false, false }, |
| 1717 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1726 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1718 std::string() }, | 1727 std::string() }, |
| 1719 // In this case, ignoring the suggested relevance scores means we keep | 1728 // In this case, ignoring the suggested relevance scores means we keep |
| 1720 // only one navsuggest result. | 1729 // only one navsuggest result. |
| 1721 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1730 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1722 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1731 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1723 "\"google:suggestrelevance\":[1]}]", | 1732 "\"google:suggestrelevance\":[1]}]", |
| 1724 { { "a", true, true }, | 1733 { { "a", true, true }, |
| 1725 { "a1.com", false, false }, | 1734 { "a1.com", false, false }, |
| 1726 { "k a", false, false }, | 1735 { "k a", false, false }, |
| 1727 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1736 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1728 std::string() }, | 1737 std::string() }, |
| 1729 { "[\"a\",[\"http://a1.com\"],[],[]," | 1738 { "[\"a\",[\"http://a1.com\"],[],[]," |
| 1730 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1739 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1731 "\"google:suggestrelevance\":[9999, 1]}]", | 1740 "\"google:suggestrelevance\":[9999, 1]}]", |
| 1732 { { "a", true, true }, | 1741 { { "a", true, true }, |
| 1733 { "a1.com", false, false }, | 1742 { "a1.com", false, false }, |
| 1734 { "k a", false, false }, | 1743 { "k a", false, false }, |
| 1735 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1744 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1736 std::string() }, | 1745 std::string() }, |
| 1737 | 1746 |
| 1738 // Ensure that all 'verbatim' results are merged with their maximum score. | 1747 // Ensure that all 'verbatim' results are merged with their maximum score. |
| 1739 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1748 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1740 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1749 "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
| 1741 { { "a2", true, true }, | 1750 { { "a2", true, true }, |
| 1742 { "a", true, true }, | 1751 { "a", true, true }, |
| 1743 { "a1", true, true }, | 1752 { "a1", true, false }, |
| 1744 { "k a", false, false }, | 1753 { "k a", false, false }, |
| 1745 kEmptyMatch, kEmptyMatch }, | 1754 kEmptyMatch, kEmptyMatch }, |
| 1746 "2" }, | 1755 "2" }, |
| 1747 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," | 1756 { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," |
| 1748 "{\"google:suggestrelevance\":[9998, 9997, 9999]," | 1757 "{\"google:suggestrelevance\":[9998, 9997, 9999]," |
| 1749 "\"google:verbatimrelevance\":0}]", | 1758 "\"google:verbatimrelevance\":0}]", |
| 1750 { { "a2", true, true }, | 1759 { { "a2", true, true }, |
| 1751 { "a", true, true }, | 1760 { "a", true, true }, |
| 1752 { "a1", true, true }, | 1761 { "a1", true, false }, |
| 1753 { "k a", false, false }, | 1762 { "k a", false, false }, |
| 1754 kEmptyMatch, kEmptyMatch }, | 1763 kEmptyMatch, kEmptyMatch }, |
| 1755 "2" }, | 1764 "2" }, |
| 1756 | 1765 |
| 1757 // Ensure that verbatim is always generated without other suggestions. | 1766 // Ensure that verbatim is always generated without other suggestions. |
| 1758 // TODO(mpearson): Ensure the value of verbatimrelevance is respected | 1767 // TODO(mpearson): Ensure the value of verbatimrelevance is respected |
| 1759 // (except when suggested relevances are ignored). | 1768 // (except when suggested relevances are ignored). |
| 1760 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", | 1769 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", |
| 1761 { { "k a", false, false }, | 1770 { { "a", true, true }, |
| 1762 { "a", true, true }, | 1771 { "k a", false, false }, |
| 1763 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1772 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1764 std::string() }, | 1773 std::string() }, |
| 1765 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", | 1774 { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", |
| 1766 { { "a", true, true }, | 1775 { { "a", true, true }, |
| 1767 { "k a", false, false }, | 1776 { "k a", false, false }, |
| 1768 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1777 kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1769 std::string() }, | 1778 std::string() }, |
| 1770 | 1779 |
| 1771 // In reorder mode, navsuggestions will not need to be demoted (because | 1780 // In reorder mode, navsuggestions will not need to be demoted (because |
| 1772 // they are marked as not allowed to be default match and will be | 1781 // they are marked as not allowed to be default match and will be |
| 1773 // reordered as necessary). | 1782 // reordered as necessary). |
| 1774 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1783 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1775 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1784 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1776 "\"google:verbatimrelevance\":9990," | 1785 "\"google:verbatimrelevance\":9990," |
| 1777 "\"google:suggestrelevance\":[9998, 9999]}]", | 1786 "\"google:suggestrelevance\":[9998, 9999]}]", |
| 1778 { { "a2.com", false, false }, | 1787 { { "a", true, true }, |
| 1788 { "a2.com", false, false }, |
| 1779 { "a1.com", false, false }, | 1789 { "a1.com", false, false }, |
| 1780 { "a", true, true }, | |
| 1781 { "k a", false, false }, | 1790 { "k a", false, false }, |
| 1782 kEmptyMatch, kEmptyMatch }, | 1791 kEmptyMatch, kEmptyMatch }, |
| 1783 std::string() }, | 1792 std::string() }, |
| 1784 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1793 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1785 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1794 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1786 "\"google:verbatimrelevance\":9990," | 1795 "\"google:verbatimrelevance\":9990," |
| 1787 "\"google:suggestrelevance\":[9999, 9998]}]", | 1796 "\"google:suggestrelevance\":[9999, 9998]}]", |
| 1788 { { "a1.com", false, false }, | 1797 { { "a", true, true }, |
| 1798 { "a1.com", false, false }, |
| 1789 { "a2.com", false, false }, | 1799 { "a2.com", false, false }, |
| 1790 { "a", true, true }, | |
| 1791 { "k a", false, false }, | 1800 { "k a", false, false }, |
| 1792 kEmptyMatch, kEmptyMatch }, | 1801 kEmptyMatch, kEmptyMatch }, |
| 1793 std::string() }, | 1802 std::string() }, |
| 1794 { "[\"a\",[\"https://a/\"],[],[]," | 1803 { "[\"a\",[\"https://a/\"],[],[]," |
| 1795 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 1804 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 1796 "\"google:suggestrelevance\":[9999]}]", | 1805 "\"google:suggestrelevance\":[9999]}]", |
| 1797 { { "https://a", false, false }, | 1806 { { "a", true, true }, |
| 1798 { "a", true, true }, | 1807 { "https://a", false, false }, |
| 1799 { "k a", false, false }, | 1808 { "k a", false, false }, |
| 1800 kEmptyMatch, kEmptyMatch, kEmptyMatch }, | 1809 kEmptyMatch, kEmptyMatch, kEmptyMatch }, |
| 1801 std::string() }, | 1810 std::string() }, |
| 1802 // Check when navsuggest scores more than verbatim and there is query | 1811 // Check when navsuggest scores more than verbatim and there is query |
| 1803 // suggestion but it scores lower. | 1812 // suggestion but it scores lower. |
| 1804 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1813 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1805 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1814 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1806 "\"google:verbatimrelevance\":9990," | 1815 "\"google:verbatimrelevance\":9990," |
| 1807 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", | 1816 "\"google:suggestrelevance\":[9998, 9999, 1300]}]", |
| 1808 { { "a2.com", false, false }, | 1817 { { "a", true, true }, |
| 1818 { "a2.com", false, false }, |
| 1809 { "a1.com", false, false }, | 1819 { "a1.com", false, false }, |
| 1810 { "a", true, true }, | 1820 { "a3", true, false }, |
| 1811 { "a3", true, true }, | |
| 1812 { "k a", false, false }, | 1821 { "k a", false, false }, |
| 1813 kEmptyMatch }, | 1822 kEmptyMatch }, |
| 1814 std::string() }, | 1823 std::string() }, |
| 1815 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1824 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1816 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1825 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1817 "\"google:verbatimrelevance\":9990," | 1826 "\"google:verbatimrelevance\":9990," |
| 1818 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", | 1827 "\"google:suggestrelevance\":[9999, 9998, 1300]}]", |
| 1819 { { "a1.com", false, false }, | 1828 { { "a", true, true }, |
| 1829 { "a1.com", false, false }, |
| 1820 { "a2.com", false, false }, | 1830 { "a2.com", false, false }, |
| 1821 { "a", true, true }, | 1831 { "a3", true, false }, |
| 1822 { "a3", true, true }, | |
| 1823 { "k a", false, false }, | 1832 { "k a", false, false }, |
| 1824 kEmptyMatch }, | 1833 kEmptyMatch }, |
| 1825 std::string() }, | 1834 std::string() }, |
| 1826 // Check when navsuggest scores more than a query suggestion. There is | 1835 // Check when navsuggest scores more than a query suggestion. There is |
| 1827 // a verbatim but it scores lower. | 1836 // a verbatim but it scores lower. |
| 1828 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1837 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1829 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1838 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1830 "\"google:verbatimrelevance\":9990," | 1839 "\"google:verbatimrelevance\":9990," |
| 1831 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 1840 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
| 1832 { { "a2.com", false, false }, | 1841 { { "a3", true, true }, |
| 1842 { "a2.com", false, false }, |
| 1833 { "a1.com", false, false }, | 1843 { "a1.com", false, false }, |
| 1834 { "a3", true, true }, | |
| 1835 { "a", true, true }, | 1844 { "a", true, true }, |
| 1836 { "k a", false, false }, | 1845 { "k a", false, false }, |
| 1837 kEmptyMatch }, | 1846 kEmptyMatch }, |
| 1838 "3" }, | 1847 "3" }, |
| 1839 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1848 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1840 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1849 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1841 "\"google:verbatimrelevance\":9990," | 1850 "\"google:verbatimrelevance\":9990," |
| 1842 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 1851 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
| 1843 { { "a1.com", false, false }, | 1852 { { "a3", true, true }, |
| 1853 { "a1.com", false, false }, |
| 1844 { "a2.com", false, false }, | 1854 { "a2.com", false, false }, |
| 1845 { "a3", true, true }, | |
| 1846 { "a", true, true }, | 1855 { "a", true, true }, |
| 1847 { "k a", false, false }, | 1856 { "k a", false, false }, |
| 1848 kEmptyMatch }, | 1857 kEmptyMatch }, |
| 1849 "3" }, | 1858 "3" }, |
| 1850 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1859 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1851 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1860 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1852 "\"google:verbatimrelevance\":0," | 1861 "\"google:verbatimrelevance\":0," |
| 1853 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", | 1862 "\"google:suggestrelevance\":[9998, 9999, 9997]}]", |
| 1854 { { "a2.com", false, false }, | 1863 { { "a3", true, true }, |
| 1864 { "a2.com", false, false }, |
| 1855 { "a1.com", false, false }, | 1865 { "a1.com", false, false }, |
| 1856 { "a3", true, true }, | |
| 1857 { "k a", false, false }, | 1866 { "k a", false, false }, |
| 1858 kEmptyMatch, kEmptyMatch }, | 1867 kEmptyMatch, kEmptyMatch }, |
| 1859 "3" }, | 1868 "3" }, |
| 1860 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1869 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1861 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1870 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1862 "\"google:verbatimrelevance\":0," | 1871 "\"google:verbatimrelevance\":0," |
| 1863 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", | 1872 "\"google:suggestrelevance\":[9999, 9998, 9997]}]", |
| 1864 { { "a1.com", false, false }, | 1873 { { "a3", true, true }, |
| 1874 { "a1.com", false, false }, |
| 1865 { "a2.com", false, false }, | 1875 { "a2.com", false, false }, |
| 1866 { "a3", true, true }, | |
| 1867 { "k a", false, false }, | 1876 { "k a", false, false }, |
| 1868 kEmptyMatch, kEmptyMatch }, | 1877 kEmptyMatch, kEmptyMatch }, |
| 1869 "3" }, | 1878 "3" }, |
| 1870 // Check when there is neither verbatim nor a query suggestion that, | 1879 // Check when there is neither verbatim nor a query suggestion that, |
| 1871 // because we can't demote navsuggestions below a query suggestion, | 1880 // because we can't demote navsuggestions below a query suggestion, |
| 1872 // we restore the keyword verbatim score. | 1881 // we restore the keyword verbatim score. |
| 1873 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1882 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1874 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1883 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1875 "\"google:verbatimrelevance\":0," | 1884 "\"google:verbatimrelevance\":0," |
| 1876 "\"google:suggestrelevance\":[9998, 9999]}]", | 1885 "\"google:suggestrelevance\":[9998, 9999]}]", |
| 1877 { { "a2.com", false, false }, | 1886 { { "a", true, true }, |
| 1887 { "a2.com", false, false }, |
| 1878 { "a1.com", false, false }, | 1888 { "a1.com", false, false }, |
| 1879 { "a", true, true }, | |
| 1880 { "k a", false, false }, | 1889 { "k a", false, false }, |
| 1881 kEmptyMatch, kEmptyMatch }, | 1890 kEmptyMatch, kEmptyMatch }, |
| 1882 std::string() }, | 1891 std::string() }, |
| 1883 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," | 1892 { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," |
| 1884 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," | 1893 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 1885 "\"google:verbatimrelevance\":0," | 1894 "\"google:verbatimrelevance\":0," |
| 1886 "\"google:suggestrelevance\":[9999, 9998]}]", | 1895 "\"google:suggestrelevance\":[9999, 9998]}]", |
| 1887 { { "a1.com", false, false }, | 1896 { { "a", true, true }, |
| 1897 { "a1.com", false, false }, |
| 1888 { "a2.com", false, false }, | 1898 { "a2.com", false, false }, |
| 1889 { "a", true, true }, | |
| 1890 { "k a", false, false }, | 1899 { "k a", false, false }, |
| 1891 kEmptyMatch, kEmptyMatch }, | 1900 kEmptyMatch, kEmptyMatch }, |
| 1892 std::string() }, | 1901 std::string() }, |
| 1893 // More checks that everything works when it's not necessary to demote. | 1902 // More checks that everything works when it's not necessary to demote. |
| 1894 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1903 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1895 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1904 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1896 "\"google:verbatimrelevance\":9990," | 1905 "\"google:verbatimrelevance\":9990," |
| 1897 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", | 1906 "\"google:suggestrelevance\":[9997, 9998, 9999]}]", |
| 1898 { { "a3", true, true }, | 1907 { { "a3", true, true }, |
| 1899 { "a2.com", false, false }, | 1908 { "a2.com", false, false }, |
| 1900 { "a1.com", false, false }, | 1909 { "a1.com", false, false }, |
| 1901 { "a", true, true }, | 1910 { "a", true, true }, |
| 1902 { "k a", false, false }, | 1911 { "k a", false, false }, |
| 1903 kEmptyMatch }, | 1912 kEmptyMatch }, |
| 1904 "3" }, | 1913 "3" }, |
| 1905 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," | 1914 { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," |
| 1906 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," | 1915 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," |
| 1907 "\"google:verbatimrelevance\":9990," | 1916 "\"google:verbatimrelevance\":9990," |
| 1908 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", | 1917 "\"google:suggestrelevance\":[9998, 9997, 9999]}]", |
| 1909 { { "a3", true, true }, | 1918 { { "a3", true, true }, |
| 1910 { "a1.com", false, false }, | 1919 { "a1.com", false, false }, |
| 1911 { "a2.com", false, false }, | 1920 { "a2.com", false, false }, |
| 1912 { "a", true, true }, | 1921 { "a", true, true }, |
| 1913 { "k a", false, false }, | 1922 { "k a", false, false }, |
| 1914 kEmptyMatch }, | 1923 kEmptyMatch }, |
| 1915 "3" }, | 1924 "3" }, |
| 1916 }; | 1925 }; |
| 1917 | 1926 |
| 1918 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 1927 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 1919 QueryForInput(ASCIIToUTF16("k a"), false, true); | 1928 // Send the query twice in order to have a synchronous pass after the first |
| 1929 // response is received. This is necessary because SearchProvider doesn't |
| 1930 // allow an asynchronous response to change the default match. |
| 1931 for (size_t j = 0; j < 2; ++j) { |
| 1932 QueryForInput(ASCIIToUTF16("k a"), false, true); |
| 1920 | 1933 |
| 1921 // Set up a default fetcher with no results. | 1934 // Set up a default fetcher with no results. |
| 1922 net::TestURLFetcher* default_fetcher = | 1935 net::TestURLFetcher* default_fetcher = |
| 1923 test_factory_.GetFetcherByID( | 1936 test_factory_.GetFetcherByID( |
| 1924 SearchProvider::kDefaultProviderURLFetcherID); | 1937 SearchProvider::kDefaultProviderURLFetcherID); |
| 1925 ASSERT_TRUE(default_fetcher); | 1938 ASSERT_TRUE(default_fetcher); |
| 1926 default_fetcher->set_response_code(200); | 1939 default_fetcher->set_response_code(200); |
| 1927 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); | 1940 default_fetcher->delegate()->OnURLFetchComplete(default_fetcher); |
| 1928 default_fetcher = NULL; | 1941 default_fetcher = NULL; |
| 1929 | 1942 |
| 1930 // Set up a keyword fetcher with provided results. | 1943 // Set up a keyword fetcher with provided results. |
| 1931 net::TestURLFetcher* keyword_fetcher = | 1944 net::TestURLFetcher* keyword_fetcher = |
| 1932 test_factory_.GetFetcherByID( | 1945 test_factory_.GetFetcherByID( |
| 1933 SearchProvider::kKeywordProviderURLFetcherID); | 1946 SearchProvider::kKeywordProviderURLFetcherID); |
| 1934 ASSERT_TRUE(keyword_fetcher); | 1947 ASSERT_TRUE(keyword_fetcher); |
| 1935 keyword_fetcher->set_response_code(200); | 1948 keyword_fetcher->set_response_code(200); |
| 1936 keyword_fetcher->SetResponseString(cases[i].json); | 1949 keyword_fetcher->SetResponseString(cases[i].json); |
| 1937 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); | 1950 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); |
| 1938 keyword_fetcher = NULL; | 1951 keyword_fetcher = NULL; |
| 1939 RunTillProviderDone(); | 1952 RunTillProviderDone(); |
| 1953 } |
| 1940 | 1954 |
| 1941 const std::string description = "for input with json=" + cases[i].json; | 1955 SCOPED_TRACE("for input with json=" + cases[i].json); |
| 1942 const ACMatches& matches = provider_->matches(); | 1956 const ACMatches& matches = provider_->matches(); |
| 1943 ASSERT_FALSE(matches.empty()); | 1957 ASSERT_FALSE(matches.empty()); |
| 1944 // Find the first match that's allowed to be the default match and check | 1958 // Find the first match that's allowed to be the default match and check |
| 1945 // its inline_autocompletion. | 1959 // its inline_autocompletion. |
| 1946 ACMatches::const_iterator it = FindDefaultMatch(matches); | 1960 ACMatches::const_iterator it = FindDefaultMatch(matches); |
| 1947 ASSERT_NE(matches.end(), it); | 1961 ASSERT_NE(matches.end(), it); |
| 1948 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 1962 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
| 1949 it->inline_autocompletion) << description; | 1963 it->inline_autocompletion); |
| 1950 | 1964 |
| 1951 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 1965 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
| 1952 size_t j = 0; | 1966 size_t j = 0; |
| 1953 // Ensure that the returned matches equal the expectations. | 1967 // Ensure that the returned matches equal the expectations. |
| 1954 for (; j < matches.size(); ++j) { | 1968 for (; j < matches.size(); ++j) { |
| 1955 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), | 1969 EXPECT_EQ(ASCIIToUTF16(cases[i].matches[j].contents), |
| 1956 matches[j].contents) << description; | 1970 matches[j].contents); |
| 1957 EXPECT_EQ(cases[i].matches[j].from_keyword, | 1971 EXPECT_EQ(cases[i].matches[j].from_keyword, |
| 1958 matches[j].keyword == ASCIIToUTF16("k")) << description; | 1972 matches[j].keyword == ASCIIToUTF16("k")); |
| 1959 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, | 1973 EXPECT_EQ(cases[i].matches[j].allowed_to_be_default_match, |
| 1960 matches[j].allowed_to_be_default_match) << description; | 1974 matches[j].allowed_to_be_default_match); |
| 1961 } | 1975 } |
| 1962 // Ensure that no expected matches are missing. | 1976 // Ensure that no expected matches are missing. |
| 1963 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) | 1977 for (; j < ARRAYSIZE_UNSAFE(cases[i].matches); ++j) { |
| 1964 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents) << | 1978 SCOPED_TRACE(" Case # " + base::IntToString(i)); |
| 1965 "Case # " << i << " " << description; | 1979 EXPECT_EQ(kNotApplicable, cases[i].matches[j].contents); |
| 1980 } |
| 1966 } | 1981 } |
| 1967 } | 1982 } |
| 1968 | 1983 |
| 1984 TEST_F(SearchProviderTest, DontInlineAutocompleteAsynchronously) { |
| 1985 // This test sends two separate queries, each receiving different JSON |
| 1986 // replies, and checks that at each stage of processing (receiving first |
| 1987 // asynchronous response, handling new keystroke synchronously / sending the |
| 1988 // second request, and receiving the second asynchronous response) we have the |
| 1989 // expected matches. In particular, receiving the second response shouldn't |
| 1990 // cause an unexpected inline autcompletion. |
| 1991 struct { |
| 1992 const std::string first_json; |
| 1993 const ExpectedMatch first_async_matches[4]; |
| 1994 const ExpectedMatch sync_matches[4]; |
| 1995 const std::string second_json; |
| 1996 const ExpectedMatch second_async_matches[4]; |
| 1997 } cases[] = { |
| 1998 // A simple test that verifies we don't inline autocomplete after the |
| 1999 // first asynchronous response, but we do at the next keystroke if the |
| 2000 // response's results were good enough. Furthermore, we should continue |
| 2001 // inline autocompleting after the second asynchronous response if the new |
| 2002 // top suggestion is the same as the old inline autocompleted suggestion. |
| 2003 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," |
| 2004 "{\"google:verbatimrelevance\":9000," |
| 2005 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2006 { { "a", true }, { "ab1", false }, { "ab2", false }, |
| 2007 kEmptyExpectedMatch }, |
| 2008 { { "ab1", true }, { "ab2", true }, { "ab", true }, |
| 2009 kEmptyExpectedMatch }, |
| 2010 "[\"ab\",[\"ab1\", \"ab2\"],[],[]," |
| 2011 "{\"google:verbatimrelevance\":9000," |
| 2012 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2013 { { "ab1", true }, { "ab2", false }, { "ab", true }, |
| 2014 kEmptyExpectedMatch } }, |
| 2015 // Ditto, just for a navigation suggestion. |
| 2016 { "[\"a\",[\"ab1.com\", \"ab2.com\"],[],[]," |
| 2017 "{\"google:verbatimrelevance\":9000," |
| 2018 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 2019 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2020 { { "a", true }, { "ab1.com", false }, { "ab2.com", false }, |
| 2021 kEmptyExpectedMatch }, |
| 2022 { { "ab1.com", true }, { "ab2.com", true }, { "ab", true }, |
| 2023 kEmptyExpectedMatch }, |
| 2024 "[\"ab\",[\"ab1.com\", \"ab2.com\"],[],[]," |
| 2025 "{\"google:verbatimrelevance\":9000," |
| 2026 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 2027 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2028 { { "ab1.com", true }, { "ab2.com", false }, { "ab", true }, |
| 2029 kEmptyExpectedMatch } }, |
| 2030 // A more realistic test of the same situation. |
| 2031 { "[\"a\",[\"abcdef\", \"abcdef.com\", \"abc\"],[],[]," |
| 2032 "{\"google:verbatimrelevance\":900," |
| 2033 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\", \"QUERY\"]," |
| 2034 "\"google:suggestrelevance\":[1250, 1200, 1000]}]", |
| 2035 { { "a", true }, { "abcdef", false }, { "abcdef.com", false }, |
| 2036 { "abc", false } }, |
| 2037 { { "abcdef", true }, { "abcdef.com", true }, { "abc", true }, |
| 2038 { "ab", true } }, |
| 2039 "[\"ab\",[\"abcdef\", \"abcdef.com\", \"abc\"],[],[]," |
| 2040 "{\"google:verbatimrelevance\":900," |
| 2041 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\", \"QUERY\"]," |
| 2042 "\"google:suggestrelevance\":[1250, 1200, 1000]}]", |
| 2043 { { "abcdef", true }, { "abcdef.com", false }, { "abc", false }, |
| 2044 { "ab", true } } }, |
| 2045 |
| 2046 // Without an original inline autcompletion, a new inline autcompletion |
| 2047 // should be rejected. |
| 2048 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," |
| 2049 "{\"google:verbatimrelevance\":9000," |
| 2050 "\"google:suggestrelevance\":[8000, 7000]}]", |
| 2051 { { "a", true }, { "ab1", false }, { "ab2", false }, |
| 2052 kEmptyExpectedMatch }, |
| 2053 { { "ab", true }, { "ab1", true }, { "ab2", true }, |
| 2054 kEmptyExpectedMatch }, |
| 2055 "[\"ab\",[\"ab1\", \"ab2\"],[],[]," |
| 2056 "{\"google:verbatimrelevance\":9000," |
| 2057 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2058 { { "ab", true }, { "ab1", false }, { "ab2", false }, |
| 2059 kEmptyExpectedMatch } }, |
| 2060 // For the same test except with the queries scored in the opposite order |
| 2061 // on the second JSON response, the queries should be ordered by the second |
| 2062 // response's scores, not the first. |
| 2063 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," |
| 2064 "{\"google:verbatimrelevance\":9000," |
| 2065 "\"google:suggestrelevance\":[8000, 7000]}]", |
| 2066 { { "a", true }, { "ab1", false }, { "ab2", false }, |
| 2067 kEmptyExpectedMatch }, |
| 2068 { { "ab", true }, { "ab1", true }, { "ab2", true }, |
| 2069 kEmptyExpectedMatch }, |
| 2070 "[\"ab\",[\"ab1\", \"ab2\"],[],[]," |
| 2071 "{\"google:verbatimrelevance\":9000," |
| 2072 "\"google:suggestrelevance\":[9001, 9002]}]", |
| 2073 { { "ab", true }, { "ab2", false }, { "ab1", false }, |
| 2074 kEmptyExpectedMatch } }, |
| 2075 // Now, the same verifications but with the new inline autocompletion as a |
| 2076 // navsuggestion. The new autocompletion should still be rejected. |
| 2077 { "[\"a\",[\"ab1.com\", \"ab2.com\"],[],[]," |
| 2078 "{\"google:verbatimrelevance\":9000," |
| 2079 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 2080 "\"google:suggestrelevance\":[8000, 7000]}]", |
| 2081 { { "a", true }, { "ab1.com", false }, { "ab2.com", false }, |
| 2082 kEmptyExpectedMatch }, |
| 2083 { { "ab", true }, { "ab1.com", true }, { "ab2.com", true }, |
| 2084 kEmptyExpectedMatch }, |
| 2085 "[\"ab\",[\"ab1.com\", \"ab2.com\"],[],[]," |
| 2086 "{\"google:verbatimrelevance\":9000," |
| 2087 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 2088 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2089 { { "ab", true }, { "ab1.com", false }, { "ab2.com", false }, |
| 2090 kEmptyExpectedMatch } }, |
| 2091 { "[\"a\",[\"ab1.com\", \"ab2.com\"],[],[]," |
| 2092 "{\"google:verbatimrelevance\":9000," |
| 2093 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 2094 "\"google:suggestrelevance\":[8000, 7000]}]", |
| 2095 { { "a", true }, { "ab1.com", false }, { "ab2.com", false }, |
| 2096 kEmptyExpectedMatch }, |
| 2097 { { "ab", true }, { "ab1.com", true }, { "ab2.com", true }, |
| 2098 kEmptyExpectedMatch }, |
| 2099 "[\"ab\",[\"ab1.com\", \"ab2.com\"],[],[]," |
| 2100 "{\"google:verbatimrelevance\":9000," |
| 2101 "\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," |
| 2102 "\"google:suggestrelevance\":[9001, 9002]}]", |
| 2103 { { "ab", true }, { "ab2.com", false }, { "ab1.com", false }, |
| 2104 kEmptyExpectedMatch } }, |
| 2105 |
| 2106 // It's okay to abandon an inline autocompletion asynchronously. |
| 2107 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," |
| 2108 "{\"google:verbatimrelevance\":9000," |
| 2109 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2110 { { "a", true }, { "ab1", false }, { "ab2", false }, |
| 2111 kEmptyExpectedMatch }, |
| 2112 { { "ab1", true }, { "ab2", true }, { "ab", true }, |
| 2113 kEmptyExpectedMatch }, |
| 2114 "[\"ab\",[\"ab1\", \"ab2\"],[],[]," |
| 2115 "{\"google:verbatimrelevance\":9000," |
| 2116 "\"google:suggestrelevance\":[8000, 7000]}]", |
| 2117 { { "ab", true }, { "ab1", true }, { "ab2", false }, |
| 2118 kEmptyExpectedMatch } }, |
| 2119 |
| 2120 // Note: it's possible that the suggest server returns a suggestion with |
| 2121 // an inline autocompletion (that as usual we delay in allowing it to |
| 2122 // be displayed as an inline autocompletion until the next keystroke), |
| 2123 // then, in response to the next keystroke, the server returns a different |
| 2124 // suggestion as an inline autocompletion. This is not likely to happen. |
| 2125 // Regardless, if it does, one could imagine three different behaviors: |
| 2126 // - keep the original inline autocompletion until the next keystroke |
| 2127 // (i.e., don't abandon an inline autocompletion asynchronously), then |
| 2128 // use the new suggestion |
| 2129 // - abandon all inline autocompletions upon the server response, then use |
| 2130 // the new suggestion on the next keystroke |
| 2131 // - ignore the new inline autocompletion provided by the server, yet |
| 2132 // possibly keep the original if it scores well in the most recent |
| 2133 // response, then use the new suggestion on the next keystroke |
| 2134 // All of these behaviors are reasonable. The main thing we want to |
| 2135 // ensure is that the second asynchronous response shouldn't cause *a new* |
| 2136 // inline autocompletion to be displayed. We test that here. |
| 2137 // The current implementation does the third bullet, but all of these |
| 2138 // behaviors seem reasonable. |
| 2139 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," |
| 2140 "{\"google:verbatimrelevance\":9000," |
| 2141 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2142 { { "a", true }, { "ab1", false }, { "ab2", false }, |
| 2143 kEmptyExpectedMatch }, |
| 2144 { { "ab1", true }, { "ab2", true }, { "ab", true }, |
| 2145 kEmptyExpectedMatch }, |
| 2146 "[\"ab\",[\"ab1\", \"ab3\"],[],[]," |
| 2147 "{\"google:verbatimrelevance\":9000," |
| 2148 "\"google:suggestrelevance\":[9002, 9900]}]", |
| 2149 { { "ab1", true }, { "ab3", false }, { "ab", true }, |
| 2150 kEmptyExpectedMatch } }, |
| 2151 { "[\"a\",[\"ab1\", \"ab2\"],[],[]," |
| 2152 "{\"google:verbatimrelevance\":9000," |
| 2153 "\"google:suggestrelevance\":[9002, 9001]}]", |
| 2154 { { "a", true }, { "ab1", false }, { "ab2", false }, |
| 2155 kEmptyExpectedMatch }, |
| 2156 { { "ab1", true }, { "ab2", true }, { "ab", true }, |
| 2157 kEmptyExpectedMatch }, |
| 2158 "[\"ab\",[\"ab1\", \"ab3\"],[],[]," |
| 2159 "{\"google:verbatimrelevance\":9000," |
| 2160 "\"google:suggestrelevance\":[8000, 9500]}]", |
| 2161 { { "ab", true }, { "ab3", false }, { "ab1", true }, |
| 2162 kEmptyExpectedMatch } }, |
| 2163 }; |
| 2164 |
| 2165 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 2166 // First, send the query "a" and receive the JSON response |first_json|. |
| 2167 ClearAllResults(); |
| 2168 QueryForInputAndWaitForFetcherResponses( |
| 2169 ASCIIToUTF16("a"), false, cases[i].first_json, std::string()); |
| 2170 |
| 2171 // Verify that the matches after the asynchronous results are as expected. |
| 2172 std::string description = "first asynchronous response for input with " |
| 2173 "first_json=" + cases[i].first_json; |
| 2174 CheckMatches(description, ARRAYSIZE_UNSAFE(cases[i].first_async_matches), |
| 2175 cases[i].first_async_matches, provider_->matches()); |
| 2176 |
| 2177 // Then, send the query "ab" and check the synchronous matches. |
| 2178 description = "synchronous response after the first keystroke after input " |
| 2179 "with first_json=" + cases[i].first_json; |
| 2180 QueryForInput(ASCIIToUTF16("ab"), false, false); |
| 2181 CheckMatches(description, ARRAYSIZE_UNSAFE(cases[i].sync_matches), |
| 2182 cases[i].sync_matches, provider_->matches()); |
| 2183 |
| 2184 // Finally, get the provided JSON response, |second_json|, and verify the |
| 2185 // matches after the second asynchronous response are as expected. |
| 2186 description = "second asynchronous response after input with first_json=" + |
| 2187 cases[i].first_json + " and second_json=" + cases[i].second_json; |
| 2188 net::TestURLFetcher* second_fetcher = |
| 2189 test_factory_.GetFetcherByID( |
| 2190 SearchProvider::kDefaultProviderURLFetcherID); |
| 2191 ASSERT_TRUE(second_fetcher); |
| 2192 second_fetcher->set_response_code(200); |
| 2193 second_fetcher->SetResponseString(cases[i].second_json); |
| 2194 second_fetcher->delegate()->OnURLFetchComplete(second_fetcher); |
| 2195 RunTillProviderDone(); |
| 2196 CheckMatches(description, ARRAYSIZE_UNSAFE(cases[i].second_async_matches), |
| 2197 cases[i].second_async_matches, provider_->matches()); |
| 2198 } |
| 2199 } |
| 2200 |
| 1969 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { | 2201 TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { |
| 1970 // We hardcode the string "term1" below, so ensure that the search term that | 2202 // We hardcode the string "term1" below, so ensure that the search term that |
| 1971 // got added to history already is that string. | 2203 // got added to history already is that string. |
| 1972 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); | 2204 ASSERT_EQ(ASCIIToUTF16("term1"), term1_); |
| 1973 base::string16 term = term1_.substr(0, term1_.length() - 1); | 2205 base::string16 term = term1_.substr(0, term1_.length() - 1); |
| 1974 | 2206 |
| 1975 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); | 2207 AddSearchToHistory(default_t_url_, term + ASCIIToUTF16("2"), 2); |
| 1976 profile_.BlockUntilHistoryProcessesPendingRequests(); | 2208 profile_.BlockUntilHistoryProcessesPendingRequests(); |
| 1977 | 2209 |
| 1978 struct { | 2210 struct { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 "\"google:suggestrelevance\":[1440, 1430, 1420, 1410, 1400, 1390]}]", | 2251 "\"google:suggestrelevance\":[1440, 1430, 1420, 1410, 1400, 1390]}]", |
| 2020 { "term", "a1", "a2", "a3", "a4", "a5" } }, | 2252 { "term", "a1", "a2", "a3", "a4", "a5" } }, |
| 2021 { term, | 2253 { term, |
| 2022 "[\"term\",[\"a1\", \"a2\", \"a3\", \"a4\"],[],[]," | 2254 "[\"term\",[\"a1\", \"a2\", \"a3\", \"a4\"],[],[]," |
| 2023 "{\"google:suggesttype\":[\"QUERY\", \"QUERY\", \"QUERY\", \"QUERY\"]," | 2255 "{\"google:suggesttype\":[\"QUERY\", \"QUERY\", \"QUERY\", \"QUERY\"]," |
| 2024 "\"google:verbatimrelevance\":1450," | 2256 "\"google:verbatimrelevance\":1450," |
| 2025 "\"google:suggestrelevance\":[1430, 1410, 1390, 1370]}]", | 2257 "\"google:suggestrelevance\":[1430, 1410, 1390, 1370]}]", |
| 2026 { "term", "a1", "a2", "term2", "a3", "a4" } } | 2258 { "term", "a1", "a2", "term2", "a3", "a4" } } |
| 2027 }; | 2259 }; |
| 2028 | 2260 |
| 2029 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2261 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 2030 QueryForInput(cases[i].input, false, false); | 2262 QueryForInputAndWaitForFetcherResponses( |
| 2031 net::TestURLFetcher* fetcher = | 2263 cases[i].input, false, cases[i].json, std::string()); |
| 2032 test_factory_.GetFetcherByID( | |
| 2033 SearchProvider::kDefaultProviderURLFetcherID); | |
| 2034 ASSERT_TRUE(fetcher); | |
| 2035 fetcher->set_response_code(200); | |
| 2036 fetcher->SetResponseString(cases[i].json); | |
| 2037 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 2038 RunTillProviderDone(); | |
| 2039 | 2264 |
| 2040 const std::string description = "for input with json=" + cases[i].json; | 2265 const std::string description = "for input with json=" + cases[i].json; |
| 2041 const ACMatches& matches = provider_->matches(); | 2266 const ACMatches& matches = provider_->matches(); |
| 2042 | 2267 |
| 2043 // Ensure no extra matches are present. | 2268 // Ensure no extra matches are present. |
| 2044 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 2269 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
| 2045 | 2270 |
| 2046 size_t j = 0; | 2271 size_t j = 0; |
| 2047 // Ensure that the returned matches equal the expectations. | 2272 // Ensure that the returned matches equal the expectations. |
| 2048 for (; j < matches.size(); ++j) | 2273 for (; j < matches.size(); ++j) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2062 AutocompleteMatch::Type match_type; | 2287 AutocompleteMatch::Type match_type; |
| 2063 bool allowed_to_be_default_match; | 2288 bool allowed_to_be_default_match; |
| 2064 }; | 2289 }; |
| 2065 const DefaultFetcherUrlInputMatch kEmptyMatch = | 2290 const DefaultFetcherUrlInputMatch kEmptyMatch = |
| 2066 { kNotApplicable, AutocompleteMatchType::NUM_TYPES, false }; | 2291 { kNotApplicable, AutocompleteMatchType::NUM_TYPES, false }; |
| 2067 struct { | 2292 struct { |
| 2068 const std::string input; | 2293 const std::string input; |
| 2069 const std::string json; | 2294 const std::string json; |
| 2070 const DefaultFetcherUrlInputMatch output[4]; | 2295 const DefaultFetcherUrlInputMatch output[4]; |
| 2071 } cases[] = { | 2296 } cases[] = { |
| 2072 // Ensure NAVIGATION matches are allowed to be listed first for URL | 2297 // Ensure NAVIGATION matches are allowed to be listed first for URL input. |
| 2073 // input regardless of whether the match is inlineable. Note that | 2298 // Non-inlineable matches should not be allowed to be the default match. |
| 2074 // non-inlineable matches should not be allowed to be the default match. | 2299 // Note that the top-scoring inlineable match is moved to the top |
| 2300 // regardless of its score. |
| 2075 { "a.com", "[\"a.com\",[\"http://b.com/\"],[],[]," | 2301 { "a.com", "[\"a.com\",[\"http://b.com/\"],[],[]," |
| 2076 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2302 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 2077 "\"google:suggestrelevance\":[9999]}]", | 2303 "\"google:suggestrelevance\":[9999]}]", |
| 2078 { { "b.com", AutocompleteMatchType::NAVSUGGEST, false }, | 2304 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2079 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2305 { "b.com", AutocompleteMatchType::NAVSUGGEST, false }, |
| 2080 kEmptyMatch, kEmptyMatch } }, | 2306 kEmptyMatch, kEmptyMatch } }, |
| 2081 { "a.com", "[\"a.com\",[\"https://b.com\"],[],[]," | 2307 { "a.com", "[\"a.com\",[\"https://b.com\"],[],[]," |
| 2082 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2308 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 2083 "\"google:suggestrelevance\":[9999]}]", | 2309 "\"google:suggestrelevance\":[9999]}]", |
| 2084 { { "https://b.com", AutocompleteMatchType::NAVSUGGEST, false }, | 2310 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2085 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2311 { "https://b.com", AutocompleteMatchType::NAVSUGGEST, false }, |
| 2086 kEmptyMatch, kEmptyMatch } }, | 2312 kEmptyMatch, kEmptyMatch } }, |
| 2087 { "a.com", "[\"a.com\",[\"http://a.com/a\"],[],[]," | 2313 { "a.com", "[\"a.com\",[\"http://a.com/a\"],[],[]," |
| 2088 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2314 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 2089 "\"google:suggestrelevance\":[9999]}]", | 2315 "\"google:suggestrelevance\":[9999]}]", |
| 2090 { { "a.com/a", AutocompleteMatchType::NAVSUGGEST, true }, | 2316 { { "a.com/a", AutocompleteMatchType::NAVSUGGEST, true }, |
| 2091 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2317 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2092 kEmptyMatch, kEmptyMatch } }, | 2318 kEmptyMatch, kEmptyMatch } }, |
| 2093 { "a.com", "[\"a.com\",[\"https://a.com\"],[],[]," | 2319 { "a.com", "[\"a.com\",[\"https://a.com\"],[],[]," |
| 2094 "{\"google:suggesttype\":[\"NAVIGATION\"]," | 2320 "{\"google:suggesttype\":[\"NAVIGATION\"]," |
| 2095 "\"google:suggestrelevance\":[9999]}]", | 2321 "\"google:suggestrelevance\":[9999]}]", |
| 2096 { { "https://a.com", AutocompleteMatchType::NAVSUGGEST, true }, | 2322 { { "https://a.com", AutocompleteMatchType::NAVSUGGEST, true }, |
| 2097 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2323 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2098 kEmptyMatch, kEmptyMatch } }, | 2324 kEmptyMatch, kEmptyMatch } }, |
| 2099 | 2325 |
| 2100 // Ensure topmost inlineable SUGGEST matches are NOT allowed for URL | 2326 // Ensure topmost inlineable SUGGEST matches are NOT allowed for URL |
| 2101 // input. SearchProvider disregards search and verbatim suggested | 2327 // input. SearchProvider disregards search and verbatim suggested |
| 2102 // relevances. | 2328 // relevances. |
| 2103 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," | 2329 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," |
| 2104 "{\"google:suggestrelevance\":[9999]}]", | 2330 "{\"google:suggestrelevance\":[9999]}]", |
| 2105 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2331 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2106 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, | 2332 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
| 2107 kEmptyMatch, kEmptyMatch } }, | 2333 kEmptyMatch, kEmptyMatch } }, |
| 2108 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," | 2334 { "a.com", "[\"a.com\",[\"a.com info\"],[],[]," |
| 2109 "{\"google:suggestrelevance\":[9999]}]", | 2335 "{\"google:suggestrelevance\":[9999]}]", |
| 2110 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2336 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2111 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, | 2337 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
| 2112 kEmptyMatch, kEmptyMatch } }, | 2338 kEmptyMatch, kEmptyMatch } }, |
| 2113 | 2339 |
| 2114 // Ensure the fallback mechanism allows inlinable NAVIGATION matches. | 2340 // Ensure the fallback mechanism allows inlineable NAVIGATION matches. |
| 2115 { "a.com", "[\"a.com\",[\"a.com info\", \"http://a.com/b\"],[],[]," | 2341 { "a.com", "[\"a.com\",[\"a.com info\", \"http://a.com/b\"],[],[]," |
| 2116 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," | 2342 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," |
| 2117 "\"google:suggestrelevance\":[9999, 9998]}]", | 2343 "\"google:suggestrelevance\":[9999, 9998]}]", |
| 2118 { { "a.com/b", AutocompleteMatchType::NAVSUGGEST, true }, | 2344 { { "a.com/b", AutocompleteMatchType::NAVSUGGEST, true }, |
| 2119 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2345 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
| 2120 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, | 2346 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2121 kEmptyMatch } }, | 2347 kEmptyMatch } }, |
| 2122 { "a.com", "[\"a.com\",[\"a.com info\", \"http://a.com/b\"],[],[]," | 2348 { "a.com", "[\"a.com\",[\"a.com info\", \"http://a.com/b\"],[],[]," |
| 2123 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," | 2349 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," |
| 2124 "\"google:suggestrelevance\":[9998, 9997]," | 2350 "\"google:suggestrelevance\":[9998, 9997]," |
| 2125 "\"google:verbatimrelevance\":9999}]", | 2351 "\"google:verbatimrelevance\":9999}]", |
| 2126 { { "a.com/b", AutocompleteMatchType::NAVSUGGEST, true }, | 2352 { { "a.com/b", AutocompleteMatchType::NAVSUGGEST, true }, |
| 2127 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2353 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2128 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, true }, | 2354 { "a.com info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
| 2129 kEmptyMatch } }, | 2355 kEmptyMatch } }, |
| 2130 | 2356 |
| 2131 // Ensure topmost non-inlineable SUGGEST matches are allowed for URL | 2357 // Ensure non-inlineable SUGGEST matches are allowed for URL input |
| 2132 // input assuming the top inlineable match is not a query (i.e., is a | 2358 // assuming the best inlineable match is not a query (i.e., is a |
| 2133 // NAVSUGGEST). | 2359 // NAVSUGGEST). The best inlineable match will be at the top of the |
| 2360 // list regardless of its score. |
| 2134 { "a.com", "[\"a.com\",[\"info\"],[],[]," | 2361 { "a.com", "[\"a.com\",[\"info\"],[],[]," |
| 2135 "{\"google:suggestrelevance\":[9999]}]", | 2362 "{\"google:suggestrelevance\":[9999]}]", |
| 2136 { { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2363 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2137 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2364 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
| 2138 kEmptyMatch, kEmptyMatch } }, | 2365 kEmptyMatch, kEmptyMatch } }, |
| 2139 { "a.com", "[\"a.com\",[\"info\"],[],[]," | 2366 { "a.com", "[\"a.com\",[\"info\"],[],[]," |
| 2140 "{\"google:suggestrelevance\":[9999]}]", | 2367 "{\"google:suggestrelevance\":[9999]}]", |
| 2141 { { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2368 { { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, |
| 2142 { "a.com", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, true }, | 2369 { "info", AutocompleteMatchType::SEARCH_SUGGEST, false }, |
| 2143 kEmptyMatch, kEmptyMatch } }, | 2370 kEmptyMatch, kEmptyMatch } }, |
| 2144 }; | 2371 }; |
| 2145 | 2372 |
| 2146 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2373 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 2147 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); | 2374 // Send the query twice in order to have a synchronous pass after the first |
| 2148 net::TestURLFetcher* fetcher = | 2375 // response is received. This is necessary because SearchProvider doesn't |
| 2149 test_factory_.GetFetcherByID( | 2376 // allow an asynchronous response to change the default match. |
| 2150 SearchProvider::kDefaultProviderURLFetcherID); | 2377 for (size_t j = 0; j < 2; ++j) { |
| 2151 ASSERT_TRUE(fetcher); | 2378 QueryForInputAndWaitForFetcherResponses( |
| 2152 fetcher->set_response_code(200); | 2379 ASCIIToUTF16(cases[i].input), false, cases[i].json, std::string()); |
| 2153 fetcher->SetResponseString(cases[i].json); | 2380 } |
| 2154 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 2155 RunTillProviderDone(); | |
| 2156 | 2381 |
| 2382 SCOPED_TRACE("input=" + cases[i].input + " json=" + cases[i].json); |
| 2157 size_t j = 0; | 2383 size_t j = 0; |
| 2158 const ACMatches& matches = provider_->matches(); | 2384 const ACMatches& matches = provider_->matches(); |
| 2159 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].output)); | 2385 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].output)); |
| 2160 // Ensure that the returned matches equal the expectations. | 2386 // Ensure that the returned matches equal the expectations. |
| 2161 for (; j < matches.size(); ++j) { | 2387 for (; j < matches.size(); ++j) { |
| 2162 EXPECT_EQ(ASCIIToUTF16(cases[i].output[j].match_contents), | 2388 EXPECT_EQ(ASCIIToUTF16(cases[i].output[j].match_contents), |
| 2163 matches[j].contents); | 2389 matches[j].contents); |
| 2164 EXPECT_EQ(cases[i].output[j].match_type, matches[j].type); | 2390 EXPECT_EQ(cases[i].output[j].match_type, matches[j].type); |
| 2165 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, | 2391 EXPECT_EQ(cases[i].output[j].allowed_to_be_default_match, |
| 2166 matches[j].allowed_to_be_default_match); | 2392 matches[j].allowed_to_be_default_match); |
| 2167 } | 2393 } |
| 2168 // Ensure that no expected matches are missing. | 2394 // Ensure that no expected matches are missing. |
| 2169 for (; j < ARRAYSIZE_UNSAFE(cases[i].output); ++j) { | 2395 for (; j < ARRAYSIZE_UNSAFE(cases[i].output); ++j) { |
| 2170 EXPECT_EQ(kNotApplicable, cases[i].output[j].match_contents); | 2396 EXPECT_EQ(kNotApplicable, cases[i].output[j].match_contents); |
| 2171 EXPECT_EQ(AutocompleteMatchType::NUM_TYPES, | 2397 EXPECT_EQ(AutocompleteMatchType::NUM_TYPES, |
| 2172 cases[i].output[j].match_type); | 2398 cases[i].output[j].match_type); |
| 2173 EXPECT_FALSE(cases[i].output[j].allowed_to_be_default_match); | 2399 EXPECT_FALSE(cases[i].output[j].allowed_to_be_default_match); |
| 2174 } | 2400 } |
| 2175 } | 2401 } |
| 2176 } | 2402 } |
| 2177 | 2403 |
| 2178 // A basic test that verifies the field trial triggered parsing logic. | 2404 // A basic test that verifies the field trial triggered parsing logic. |
| 2179 TEST_F(SearchProviderTest, FieldTrialTriggeredParsing) { | 2405 TEST_F(SearchProviderTest, FieldTrialTriggeredParsing) { |
| 2180 QueryForInput(ASCIIToUTF16("foo"), false, false); | 2406 QueryForInputAndWaitForFetcherResponses( |
| 2181 | 2407 ASCIIToUTF16("foo"), false, |
| 2182 // Make sure the default providers suggest service was queried. | |
| 2183 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | |
| 2184 SearchProvider::kDefaultProviderURLFetcherID); | |
| 2185 ASSERT_TRUE(fetcher); | |
| 2186 | |
| 2187 // Tell the SearchProvider the suggest query is done. | |
| 2188 fetcher->set_response_code(200); | |
| 2189 fetcher->SetResponseString( | |
| 2190 "[\"foo\",[\"foo bar\"],[\"\"],[]," | 2408 "[\"foo\",[\"foo bar\"],[\"\"],[]," |
| 2191 "{\"google:suggesttype\":[\"QUERY\"]," | 2409 "{\"google:suggesttype\":[\"QUERY\"]," |
| 2192 "\"google:fieldtrialtriggered\":true}]"); | 2410 "\"google:fieldtrialtriggered\":true}]", |
| 2193 fetcher->delegate()->OnURLFetchComplete(fetcher); | 2411 std::string()); |
| 2194 fetcher = NULL; | |
| 2195 | |
| 2196 // Run till the history results complete. | |
| 2197 RunTillProviderDone(); | |
| 2198 | 2412 |
| 2199 { | 2413 { |
| 2200 // Check for the match and field trial triggered bits. | 2414 // Check for the match and field trial triggered bits. |
| 2201 AutocompleteMatch match; | 2415 AutocompleteMatch match; |
| 2202 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("foo bar"), &match)); | 2416 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("foo bar"), &match)); |
| 2203 ProvidersInfo providers_info; | 2417 ProvidersInfo providers_info; |
| 2204 provider_->AddProviderInfo(&providers_info); | 2418 provider_->AddProviderInfo(&providers_info); |
| 2205 ASSERT_EQ(1U, providers_info.size()); | 2419 ASSERT_EQ(1U, providers_info.size()); |
| 2206 EXPECT_EQ(1, providers_info[0].field_trial_triggered_size()); | 2420 EXPECT_EQ(1, providers_info[0].field_trial_triggered_size()); |
| 2207 EXPECT_EQ(1, providers_info[0].field_trial_triggered_in_session_size()); | 2421 EXPECT_EQ(1, providers_info[0].field_trial_triggered_in_session_size()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2277 { "abc.com ", "http://www.abc.com", | 2491 { "abc.com ", "http://www.abc.com", |
| 2278 "www.abc.com", std::string(), true, true }, | 2492 "www.abc.com", std::string(), true, true }, |
| 2279 { "abc.com/ ", "http://www.abc.com", | 2493 { "abc.com/ ", "http://www.abc.com", |
| 2280 "www.abc.com", std::string(), true, true }, | 2494 "www.abc.com", std::string(), true, true }, |
| 2281 { "abc.com ", "http://www.abc.com/bar", | 2495 { "abc.com ", "http://www.abc.com/bar", |
| 2282 "www.abc.com/bar", "/bar", false, false }, | 2496 "www.abc.com/bar", "/bar", false, false }, |
| 2283 | 2497 |
| 2284 // A suggestion that's equivalent to what the input gets fixed up to | 2498 // A suggestion that's equivalent to what the input gets fixed up to |
| 2285 // should be inlined. | 2499 // should be inlined. |
| 2286 { "abc.com:", "http://abc.com/", | 2500 { "abc.com:", "http://abc.com/", |
| 2287 "abc.com", "", true, true }, | 2501 "abc.com", std::string(), true, true }, |
| 2288 { "abc.com:", "http://www.abc.com", | 2502 { "abc.com:", "http://www.abc.com", |
| 2289 "www.abc.com", "", true, true }, | 2503 "www.abc.com", std::string(), true, true }, |
| 2290 | 2504 |
| 2291 // Inline matches when the input is a leading substring of the scheme. | 2505 // Inline matches when the input is a leading substring of the scheme. |
| 2292 { "h", "http://www.abc.com", | 2506 { "h", "http://www.abc.com", |
| 2293 "http://www.abc.com", "ttp://www.abc.com", true, false }, | 2507 "http://www.abc.com", "ttp://www.abc.com", true, false }, |
| 2294 { "http", "http://www.abc.com", | 2508 { "http", "http://www.abc.com", |
| 2295 "http://www.abc.com", "://www.abc.com", true, false }, | 2509 "http://www.abc.com", "://www.abc.com", true, false }, |
| 2296 | 2510 |
| 2297 // Inline matches when the input is a leading substring of the full URL. | 2511 // Inline matches when the input is a leading substring of the full URL. |
| 2298 { "http:", "http://www.abc.com", | 2512 { "http:", "http://www.abc.com", |
| 2299 "http://www.abc.com", "//www.abc.com", true, false }, | 2513 "http://www.abc.com", "//www.abc.com", true, false }, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2364 "c.com/path/file.htm?q=x#foo", true, false }, | 2578 "c.com/path/file.htm?q=x#foo", true, false }, |
| 2365 { "ab", "https://www.abc.com/path/file.htm?q=x#foo", | 2579 { "ab", "https://www.abc.com/path/file.htm?q=x#foo", |
| 2366 "https://www.abc.com/path/file.htm?q=x#foo", | 2580 "https://www.abc.com/path/file.htm?q=x#foo", |
| 2367 "c.com/path/file.htm?q=x#foo", true, false }, | 2581 "c.com/path/file.htm?q=x#foo", true, false }, |
| 2368 { "ab", "https://abc.com/path/file.htm?q=x#foo", | 2582 { "ab", "https://abc.com/path/file.htm?q=x#foo", |
| 2369 "https://abc.com/path/file.htm?q=x#foo", | 2583 "https://abc.com/path/file.htm?q=x#foo", |
| 2370 "c.com/path/file.htm?q=x#foo", true, false }, | 2584 "c.com/path/file.htm?q=x#foo", true, false }, |
| 2371 | 2585 |
| 2372 // Forced query input should inline and retain the "?" prefix. | 2586 // Forced query input should inline and retain the "?" prefix. |
| 2373 { "?http://www.ab", "http://www.abc.com", | 2587 { "?http://www.ab", "http://www.abc.com", |
| 2374 "?http://www.abc.com", "c.com", true, false }, | 2588 "?http://www.abc.com", "c.com", true, false }, |
| 2375 { "?www.ab", "http://www.abc.com", | 2589 { "?www.ab", "http://www.abc.com", |
| 2376 "?www.abc.com", "c.com", true, false }, | 2590 "?www.abc.com", "c.com", true, false }, |
| 2377 { "?ab", "http://www.abc.com", | 2591 { "?ab", "http://www.abc.com", |
| 2378 "?www.abc.com", "c.com", true, false }, | 2592 "?www.abc.com", "c.com", true, false }, |
| 2379 { "?abc.com", "http://www.abc.com", | 2593 { "?abc.com", "http://www.abc.com", |
| 2380 "?www.abc.com", "", true, true }, | 2594 "?www.abc.com", std::string(), true, true }, |
| 2381 }; | 2595 }; |
| 2382 | 2596 |
| 2383 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2597 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 2384 // First test regular mode. | 2598 // First test regular mode. |
| 2385 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); | 2599 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); |
| 2386 AutocompleteMatch match( | 2600 SearchSuggestionParser::NavigationResult result( |
| 2387 provider_->NavigationToMatch(SearchSuggestionParser::NavigationResult( | 2601 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), |
| 2388 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), | 2602 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), |
| 2389 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), | 2603 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()); |
| 2390 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()))); | 2604 result.set_received_after_last_keystroke(false); |
| 2605 AutocompleteMatch match(provider_->NavigationToMatch(result)); |
| 2391 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 2606 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
| 2392 match.inline_autocompletion); | 2607 match.inline_autocompletion); |
| 2393 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit); | 2608 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit); |
| 2394 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_regular_mode, | 2609 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_regular_mode, |
| 2395 match.allowed_to_be_default_match); | 2610 match.allowed_to_be_default_match); |
| 2396 | 2611 |
| 2397 // Then test prevent-inline-autocomplete mode. | 2612 // Then test prevent-inline-autocomplete mode. |
| 2398 QueryForInput(ASCIIToUTF16(cases[i].input), true, false); | 2613 QueryForInput(ASCIIToUTF16(cases[i].input), true, false); |
| 2614 SearchSuggestionParser::NavigationResult result_prevent_inline( |
| 2615 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), |
| 2616 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), |
| 2617 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()); |
| 2618 result_prevent_inline.set_received_after_last_keystroke(false); |
| 2399 AutocompleteMatch match_prevent_inline( | 2619 AutocompleteMatch match_prevent_inline( |
| 2400 provider_->NavigationToMatch(SearchSuggestionParser::NavigationResult( | 2620 provider_->NavigationToMatch(result_prevent_inline)); |
| 2401 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), | |
| 2402 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), | |
| 2403 false, 0, false, ASCIIToUTF16(cases[i].input), std::string()))); | |
| 2404 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), | 2621 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
| 2405 match_prevent_inline.inline_autocompletion); | 2622 match_prevent_inline.inline_autocompletion); |
| 2406 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), | 2623 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), |
| 2407 match_prevent_inline.fill_into_edit); | 2624 match_prevent_inline.fill_into_edit); |
| 2408 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_prevent_inline_mode, | 2625 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_prevent_inline_mode, |
| 2409 match_prevent_inline.allowed_to_be_default_match); | 2626 match_prevent_inline.allowed_to_be_default_match); |
| 2410 } | 2627 } |
| 2411 } | 2628 } |
| 2412 | 2629 |
| 2413 // Verifies that "http://" is not trimmed for input that is a leading substring. | 2630 // Verifies that "http://" is not trimmed for input that is a leading substring. |
| 2414 TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) { | 2631 TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) { |
| 2415 const base::string16 input(ASCIIToUTF16("ht")); | 2632 const base::string16 input(ASCIIToUTF16("ht")); |
| 2416 const base::string16 url(ASCIIToUTF16("http://a.com")); | 2633 const base::string16 url(ASCIIToUTF16("http://a.com")); |
| 2417 const SearchSuggestionParser::NavigationResult result( | 2634 SearchSuggestionParser::NavigationResult result( |
| 2418 ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), | 2635 ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), |
| 2419 AutocompleteMatchType::NAVSUGGEST, | 2636 AutocompleteMatchType::NAVSUGGEST, |
| 2420 base::string16(), std::string(), false, 0, false, input, std::string()); | 2637 base::string16(), std::string(), false, 0, false, input, std::string()); |
| 2638 result.set_received_after_last_keystroke(false); |
| 2421 | 2639 |
| 2422 // Check the offset and strings when inline autocompletion is allowed. | 2640 // Check the offset and strings when inline autocompletion is allowed. |
| 2423 QueryForInput(input, false, false); | 2641 QueryForInput(input, false, false); |
| 2424 AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); | 2642 AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); |
| 2425 EXPECT_EQ(url, match_inline.fill_into_edit); | 2643 EXPECT_EQ(url, match_inline.fill_into_edit); |
| 2426 EXPECT_EQ(url.substr(2), match_inline.inline_autocompletion); | 2644 EXPECT_EQ(url.substr(2), match_inline.inline_autocompletion); |
| 2427 EXPECT_TRUE(match_inline.allowed_to_be_default_match); | 2645 EXPECT_TRUE(match_inline.allowed_to_be_default_match); |
| 2428 EXPECT_EQ(url, match_inline.contents); | 2646 EXPECT_EQ(url, match_inline.contents); |
| 2429 | 2647 |
| 2430 // Check the same strings when inline autocompletion is prevented. | 2648 // Check the same strings when inline autocompletion is prevented. |
| 2431 QueryForInput(input, true, false); | 2649 QueryForInput(input, true, false); |
| 2432 AutocompleteMatch match_prevent(provider_->NavigationToMatch(result)); | 2650 AutocompleteMatch match_prevent(provider_->NavigationToMatch(result)); |
| 2433 EXPECT_EQ(url, match_prevent.fill_into_edit); | 2651 EXPECT_EQ(url, match_prevent.fill_into_edit); |
| 2434 EXPECT_FALSE(match_prevent.allowed_to_be_default_match); | 2652 EXPECT_FALSE(match_prevent.allowed_to_be_default_match); |
| 2435 EXPECT_EQ(url, match_prevent.contents); | 2653 EXPECT_EQ(url, match_prevent.contents); |
| 2436 } | 2654 } |
| 2437 | 2655 |
| 2438 // Verifies that input "w" marks a more significant domain label than "www.". | 2656 // Verifies that input "w" marks a more significant domain label than "www.". |
| 2439 TEST_F(SearchProviderTest, NavigationInlineDomainClassify) { | 2657 TEST_F(SearchProviderTest, NavigationInlineDomainClassify) { |
| 2440 QueryForInput(ASCIIToUTF16("w"), false, false); | 2658 QueryForInput(ASCIIToUTF16("w"), false, false); |
| 2441 AutocompleteMatch match( | 2659 SearchSuggestionParser::NavigationResult result( |
| 2442 provider_->NavigationToMatch(SearchSuggestionParser::NavigationResult( | 2660 ChromeAutocompleteSchemeClassifier(&profile_), |
| 2443 ChromeAutocompleteSchemeClassifier(&profile_), | 2661 GURL("http://www.wow.com"), AutocompleteMatchType::NAVSUGGEST, |
| 2444 GURL("http://www.wow.com"), | 2662 base::string16(), std::string(), false, 0, false, ASCIIToUTF16("w"), |
| 2445 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), | 2663 std::string()); |
| 2446 false, 0, false, ASCIIToUTF16("w"), std::string()))); | 2664 result.set_received_after_last_keystroke(false); |
| 2665 AutocompleteMatch match(provider_->NavigationToMatch(result)); |
| 2447 EXPECT_EQ(ASCIIToUTF16("ow.com"), match.inline_autocompletion); | 2666 EXPECT_EQ(ASCIIToUTF16("ow.com"), match.inline_autocompletion); |
| 2448 EXPECT_TRUE(match.allowed_to_be_default_match); | 2667 EXPECT_TRUE(match.allowed_to_be_default_match); |
| 2449 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.fill_into_edit); | 2668 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.fill_into_edit); |
| 2450 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.contents); | 2669 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.contents); |
| 2451 | 2670 |
| 2452 // Ensure that the match for input "w" is marked on "wow" and not "www". | 2671 // Ensure that the match for input "w" is marked on "wow" and not "www". |
| 2453 ASSERT_EQ(3U, match.contents_class.size()); | 2672 ASSERT_EQ(3U, match.contents_class.size()); |
| 2454 EXPECT_EQ(0U, match.contents_class[0].offset); | 2673 EXPECT_EQ(0U, match.contents_class[0].offset); |
| 2455 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 2674 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |
| 2456 match.contents_class[0].style); | 2675 match.contents_class[0].style); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2504 "\"google:suggesttype\":[\"QUERY\",\"ENTITY\"]}]", | 2723 "\"google:suggesttype\":[\"QUERY\",\"ENTITY\"]}]", |
| 2505 { { "x", "", "", "x", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, | 2724 { { "x", "", "", "x", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, |
| 2506 { "xy", "", "", "xy", AutocompleteMatchType::SEARCH_SUGGEST }, | 2725 { "xy", "", "", "xy", AutocompleteMatchType::SEARCH_SUGGEST }, |
| 2507 { "xy", "A", "p=v", "xy", | 2726 { "xy", "A", "p=v", "xy", |
| 2508 AutocompleteMatchType::SEARCH_SUGGEST_ENTITY }, | 2727 AutocompleteMatchType::SEARCH_SUGGEST_ENTITY }, |
| 2509 kEmptyMatch, | 2728 kEmptyMatch, |
| 2510 kEmptyMatch | 2729 kEmptyMatch |
| 2511 }, | 2730 }, |
| 2512 }, | 2731 }, |
| 2513 }; | 2732 }; |
| 2514 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2733 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 2515 QueryForInput(ASCIIToUTF16(cases[i].input_text), false, false); | 2734 QueryForInputAndWaitForFetcherResponses( |
| 2516 | 2735 ASCIIToUTF16(cases[i].input_text), false, cases[i].response_json, |
| 2517 // Set up a default fetcher with provided results. | 2736 std::string()); |
| 2518 net::TestURLFetcher* fetcher = | |
| 2519 test_factory_.GetFetcherByID( | |
| 2520 SearchProvider::kDefaultProviderURLFetcherID); | |
| 2521 ASSERT_TRUE(fetcher); | |
| 2522 fetcher->set_response_code(200); | |
| 2523 fetcher->SetResponseString(cases[i].response_json); | |
| 2524 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 2525 | |
| 2526 RunTillProviderDone(); | |
| 2527 | 2737 |
| 2528 const ACMatches& matches = provider_->matches(); | 2738 const ACMatches& matches = provider_->matches(); |
| 2529 ASSERT_FALSE(matches.empty()); | 2739 ASSERT_FALSE(matches.empty()); |
| 2530 | 2740 |
| 2531 SCOPED_TRACE("for input with json = " + cases[i].response_json); | 2741 SCOPED_TRACE("for input with json = " + cases[i].response_json); |
| 2532 | 2742 |
| 2533 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 2743 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
| 2534 size_t j = 0; | 2744 size_t j = 0; |
| 2535 // Ensure that the returned matches equal the expectations. | 2745 // Ensure that the returned matches equal the expectations. |
| 2536 for (; j < matches.size(); ++j) { | 2746 for (; j < matches.size(); ++j) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2639 "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", | 2849 "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", |
| 2640 { { "a", false, AutocompleteMatchType::SEARCH_OTHER_ENGINE, true}, | 2850 { { "a", false, AutocompleteMatchType::SEARCH_OTHER_ENGINE, true}, |
| 2641 { "k a", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false }, | 2851 { "k a", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false }, |
| 2642 { "ab", false, AutocompleteMatchType::SEARCH_SUGGEST, false }, | 2852 { "ab", false, AutocompleteMatchType::SEARCH_SUGGEST, false }, |
| 2643 { "c", false, AutocompleteMatchType::SEARCH_SUGGEST, true }, | 2853 { "c", false, AutocompleteMatchType::SEARCH_SUGGEST, true }, |
| 2644 { "b", false, AutocompleteMatchType::SEARCH_SUGGEST, true } | 2854 { "b", false, AutocompleteMatchType::SEARCH_SUGGEST, true } |
| 2645 }, | 2855 }, |
| 2646 } | 2856 } |
| 2647 }; | 2857 }; |
| 2648 | 2858 |
| 2649 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2859 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 2650 QueryForInput(ASCIIToUTF16(cases[i].input_text), false, | 2860 QueryForInputAndWaitForFetcherResponses( |
| 2651 cases[i].prefer_keyword_provider_results); | 2861 ASCIIToUTF16(cases[i].input_text), |
| 2652 | 2862 cases[i].prefer_keyword_provider_results, |
| 2653 // Set up a default fetcher with provided results. | 2863 cases[i].default_provider_response_json, |
| 2654 net::TestURLFetcher* fetcher = | 2864 cases[i].prefer_keyword_provider_results ? |
| 2655 test_factory_.GetFetcherByID( | 2865 cases[i].keyword_provider_response_json : std::string()); |
| 2656 SearchProvider::kDefaultProviderURLFetcherID); | |
| 2657 ASSERT_TRUE(fetcher); | |
| 2658 fetcher->set_response_code(200); | |
| 2659 fetcher->SetResponseString(cases[i].default_provider_response_json); | |
| 2660 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 2661 | |
| 2662 if (cases[i].prefer_keyword_provider_results) { | |
| 2663 // Set up a keyword fetcher with provided results. | |
| 2664 net::TestURLFetcher* keyword_fetcher = | |
| 2665 test_factory_.GetFetcherByID( | |
| 2666 SearchProvider::kKeywordProviderURLFetcherID); | |
| 2667 ASSERT_TRUE(keyword_fetcher); | |
| 2668 keyword_fetcher->set_response_code(200); | |
| 2669 keyword_fetcher->SetResponseString( | |
| 2670 cases[i].keyword_provider_response_json); | |
| 2671 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); | |
| 2672 keyword_fetcher = NULL; | |
| 2673 } | |
| 2674 | |
| 2675 RunTillProviderDone(); | |
| 2676 | 2866 |
| 2677 const std::string description = | 2867 const std::string description = |
| 2678 "for input with json =" + cases[i].default_provider_response_json; | 2868 "for input with json =" + cases[i].default_provider_response_json; |
| 2679 const ACMatches& matches = provider_->matches(); | 2869 const ACMatches& matches = provider_->matches(); |
| 2680 // The top match must inline and score as highly as calculated verbatim. | 2870 // The top match must inline and score as highly as calculated verbatim. |
| 2681 ASSERT_FALSE(matches.empty()); | 2871 ASSERT_FALSE(matches.empty()); |
| 2682 EXPECT_GE(matches[0].relevance, 1300); | 2872 EXPECT_GE(matches[0].relevance, 1300); |
| 2683 | 2873 |
| 2684 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 2874 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
| 2685 // Ensure that the returned matches equal the expectations. | 2875 // Ensure that the returned matches equal the expectations. |
| 2686 for (size_t j = 0; j < matches.size(); ++j) { | 2876 for (size_t j = 0; j < matches.size(); ++j) { |
| 2687 SCOPED_TRACE(description); | 2877 SCOPED_TRACE(description); |
| 2688 EXPECT_EQ(cases[i].matches[j].contents, | 2878 EXPECT_EQ(cases[i].matches[j].contents, |
| 2689 base::UTF16ToUTF8(matches[j].contents)); | 2879 base::UTF16ToUTF8(matches[j].contents)); |
| 2690 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched, | 2880 EXPECT_EQ(cases[i].matches[j].allowed_to_be_prefetched, |
| 2691 SearchProvider::ShouldPrefetch(matches[j])); | 2881 SearchProvider::ShouldPrefetch(matches[j])); |
| 2692 EXPECT_EQ(cases[i].matches[j].type, matches[j].type); | 2882 EXPECT_EQ(cases[i].matches[j].type, matches[j].type); |
| 2693 EXPECT_EQ(cases[i].matches[j].from_keyword, | 2883 EXPECT_EQ(cases[i].matches[j].from_keyword, |
| 2694 matches[j].keyword == ASCIIToUTF16("k")); | 2884 matches[j].keyword == ASCIIToUTF16("k")); |
| 2695 } | 2885 } |
| 2696 } | 2886 } |
| 2697 } | 2887 } |
| 2698 | 2888 |
| 2699 TEST_F(SearchProviderTest, XSSIGuardedJSONParsing_InvalidResponse) { | 2889 TEST_F(SearchProviderTest, XSSIGuardedJSONParsing_InvalidResponse) { |
| 2700 ClearAllResults(); | 2890 ClearAllResults(); |
| 2701 | 2891 |
| 2702 std::string input_str("abc"); | 2892 std::string input_str("abc"); |
| 2703 QueryForInput(ASCIIToUTF16(input_str), false, false); | 2893 QueryForInputAndWaitForFetcherResponses( |
| 2704 | 2894 ASCIIToUTF16(input_str), false, "this is a bad non-json response", |
| 2705 // Set up a default fetcher with provided results. | 2895 std::string()); |
| 2706 net::TestURLFetcher* fetcher = | |
| 2707 test_factory_.GetFetcherByID( | |
| 2708 SearchProvider::kDefaultProviderURLFetcherID); | |
| 2709 ASSERT_TRUE(fetcher); | |
| 2710 fetcher->set_response_code(200); | |
| 2711 fetcher->SetResponseString("this is a bad non-json response"); | |
| 2712 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 2713 | |
| 2714 RunTillProviderDone(); | |
| 2715 | 2896 |
| 2716 const ACMatches& matches = provider_->matches(); | 2897 const ACMatches& matches = provider_->matches(); |
| 2717 | 2898 |
| 2718 // Should have exactly one "search what you typed" match | 2899 // Should have exactly one "search what you typed" match |
| 2719 ASSERT_TRUE(matches.size() == 1); | 2900 ASSERT_TRUE(matches.size() == 1); |
| 2720 EXPECT_EQ(input_str, base::UTF16ToUTF8(matches[0].contents)); | 2901 EXPECT_EQ(input_str, base::UTF16ToUTF8(matches[0].contents)); |
| 2721 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 2902 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
| 2722 matches[0].type); | 2903 matches[0].type); |
| 2723 } | 2904 } |
| 2724 | 2905 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2766 "{\"google:suggesttype\":[\"QUERY\",\"QUERY\"]," | 2947 "{\"google:suggesttype\":[\"QUERY\",\"QUERY\"]," |
| 2767 "\"google:suggestrelevance\":[1, 2]}]", | 2948 "\"google:suggestrelevance\":[1, 2]}]", |
| 2768 { { "a", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, | 2949 { { "a", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, |
| 2769 { "c", AutocompleteMatchType::SEARCH_SUGGEST }, | 2950 { "c", AutocompleteMatchType::SEARCH_SUGGEST }, |
| 2770 { "b", AutocompleteMatchType::SEARCH_SUGGEST }, | 2951 { "b", AutocompleteMatchType::SEARCH_SUGGEST }, |
| 2771 kEmptyMatch, | 2952 kEmptyMatch, |
| 2772 }, | 2953 }, |
| 2773 }, | 2954 }, |
| 2774 }; | 2955 }; |
| 2775 | 2956 |
| 2776 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 2957 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 2777 ClearAllResults(); | 2958 ClearAllResults(); |
| 2778 QueryForInput(ASCIIToUTF16(cases[i].input_text), false, false); | 2959 QueryForInputAndWaitForFetcherResponses( |
| 2779 | 2960 ASCIIToUTF16(cases[i].input_text), false, |
| 2780 // Set up a default fetcher with provided results. | 2961 cases[i].default_provider_response_json, std::string()); |
| 2781 net::TestURLFetcher* fetcher = | |
| 2782 test_factory_.GetFetcherByID( | |
| 2783 SearchProvider::kDefaultProviderURLFetcherID); | |
| 2784 ASSERT_TRUE(fetcher); | |
| 2785 fetcher->set_response_code(200); | |
| 2786 fetcher->SetResponseString(cases[i].default_provider_response_json); | |
| 2787 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 2788 | |
| 2789 RunTillProviderDone(); | |
| 2790 | 2962 |
| 2791 const ACMatches& matches = provider_->matches(); | 2963 const ACMatches& matches = provider_->matches(); |
| 2792 // The top match must inline and score as highly as calculated verbatim. | 2964 // The top match must inline and score as highly as calculated verbatim. |
| 2793 ASSERT_FALSE(matches.empty()); | 2965 ASSERT_FALSE(matches.empty()); |
| 2794 EXPECT_GE(matches[0].relevance, 1300); | 2966 EXPECT_GE(matches[0].relevance, 1300); |
| 2795 | 2967 |
| 2796 SCOPED_TRACE("for case: " + base::IntToString(i)); | 2968 SCOPED_TRACE("for case: " + base::IntToString(i)); |
| 2797 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); | 2969 ASSERT_LE(matches.size(), ARRAYSIZE_UNSAFE(cases[i].matches)); |
| 2798 size_t j = 0; | 2970 size_t j = 0; |
| 2799 // Ensure that the returned matches equal the expectations. | 2971 // Ensure that the returned matches equal the expectations. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2814 // Test that deletion url gets set on an AutocompleteMatch when available for a | 2986 // Test that deletion url gets set on an AutocompleteMatch when available for a |
| 2815 // personalized query or a personalized URL. | 2987 // personalized query or a personalized URL. |
| 2816 TEST_F(SearchProviderTest, ParseDeletionUrl) { | 2988 TEST_F(SearchProviderTest, ParseDeletionUrl) { |
| 2817 struct Match { | 2989 struct Match { |
| 2818 std::string contents; | 2990 std::string contents; |
| 2819 std::string deletion_url; | 2991 std::string deletion_url; |
| 2820 AutocompleteMatchType::Type type; | 2992 AutocompleteMatchType::Type type; |
| 2821 }; | 2993 }; |
| 2822 | 2994 |
| 2823 const Match kEmptyMatch = { | 2995 const Match kEmptyMatch = { |
| 2824 kNotApplicable, "", AutocompleteMatchType::NUM_TYPES | 2996 kNotApplicable, std::string(), AutocompleteMatchType::NUM_TYPES |
| 2825 }; | 2997 }; |
| 2826 | 2998 |
| 2827 const char* url[] = { | 2999 const char* url[] = { |
| 2828 "http://defaultturl/complete/deleteitems" | 3000 "http://defaultturl/complete/deleteitems" |
| 2829 "?delq=ab&client=chrome&deltok=xsrf124", | 3001 "?delq=ab&client=chrome&deltok=xsrf124", |
| 2830 "http://defaultturl/complete/deleteitems" | 3002 "http://defaultturl/complete/deleteitems" |
| 2831 "?delq=www.amazon.com&client=chrome&deltok=xsrf123", | 3003 "?delq=www.amazon.com&client=chrome&deltok=xsrf123", |
| 2832 }; | 3004 }; |
| 2833 | 3005 |
| 2834 struct { | 3006 struct { |
| 2835 const std::string input_text; | 3007 const std::string input_text; |
| 2836 const std::string response_json; | 3008 const std::string response_json; |
| 2837 const Match matches[5]; | 3009 const Match matches[5]; |
| 2838 } cases[] = { | 3010 } cases[] = { |
| 2839 // A deletion URL on a personalized query should be reflected in the | 3011 // A deletion URL on a personalized query should be reflected in the |
| 2840 // resulting AutocompleteMatch. | 3012 // resulting AutocompleteMatch. |
| 2841 { "a", | 3013 { "a", |
| 2842 "[\"a\",[\"ab\", \"ac\",\"www.amazon.com\"],[],[]," | 3014 "[\"a\",[\"ab\", \"ac\",\"www.amazon.com\"],[],[]," |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2882 { { "a", "", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, | 3054 { { "a", "", AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED }, |
| 2883 { "ac", "", AutocompleteMatchType::SEARCH_SUGGEST }, | 3055 { "ac", "", AutocompleteMatchType::SEARCH_SUGGEST }, |
| 2884 { "ab", "", AutocompleteMatchType::SEARCH_SUGGEST }, | 3056 { "ab", "", AutocompleteMatchType::SEARCH_SUGGEST }, |
| 2885 { "www.amazon.com", "", | 3057 { "www.amazon.com", "", |
| 2886 AutocompleteMatchType::NAVSUGGEST_PERSONALIZED }, | 3058 AutocompleteMatchType::NAVSUGGEST_PERSONALIZED }, |
| 2887 kEmptyMatch, | 3059 kEmptyMatch, |
| 2888 }, | 3060 }, |
| 2889 }, | 3061 }, |
| 2890 }; | 3062 }; |
| 2891 | 3063 |
| 2892 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { | 3064 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 2893 QueryForInput(ASCIIToUTF16(cases[i].input_text), false, false); | 3065 QueryForInputAndWaitForFetcherResponses( |
| 2894 | 3066 ASCIIToUTF16(cases[i].input_text), false, cases[i].response_json, |
| 2895 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | 3067 std::string()); |
| 2896 SearchProvider::kDefaultProviderURLFetcherID); | |
| 2897 ASSERT_TRUE(fetcher); | |
| 2898 fetcher->set_response_code(200); | |
| 2899 fetcher->SetResponseString(cases[i].response_json); | |
| 2900 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 2901 | |
| 2902 RunTillProviderDone(); | |
| 2903 | 3068 |
| 2904 const ACMatches& matches = provider_->matches(); | 3069 const ACMatches& matches = provider_->matches(); |
| 2905 ASSERT_FALSE(matches.empty()); | 3070 ASSERT_FALSE(matches.empty()); |
| 2906 | 3071 |
| 2907 SCOPED_TRACE("for input with json = " + cases[i].response_json); | 3072 SCOPED_TRACE("for input with json = " + cases[i].response_json); |
| 2908 | 3073 |
| 2909 for (size_t j = 0; j < matches.size(); ++j) { | 3074 for (size_t j = 0; j < matches.size(); ++j) { |
| 2910 const Match& match = cases[i].matches[j]; | 3075 const Match& match = cases[i].matches[j]; |
| 2911 SCOPED_TRACE(" and match index: " + base::IntToString(j)); | 3076 SCOPED_TRACE(" and match index: " + base::IntToString(j)); |
| 2912 EXPECT_EQ(match.contents, base::UTF16ToUTF8(matches[j].contents)); | 3077 EXPECT_EQ(match.contents, base::UTF16ToUTF8(matches[j].contents)); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3127 EXPECT_FALSE(FindMatchWithContents(ASCIIToUTF16("flash games"), &games)); | 3292 EXPECT_FALSE(FindMatchWithContents(ASCIIToUTF16("flash games"), &games)); |
| 3128 } | 3293 } |
| 3129 | 3294 |
| 3130 // Verifies that duplicates are preserved in AddMatchToMap(). | 3295 // Verifies that duplicates are preserved in AddMatchToMap(). |
| 3131 TEST_F(SearchProviderTest, CheckDuplicateMatchesSaved) { | 3296 TEST_F(SearchProviderTest, CheckDuplicateMatchesSaved) { |
| 3132 AddSearchToHistory(default_t_url_, ASCIIToUTF16("a"), 1); | 3297 AddSearchToHistory(default_t_url_, ASCIIToUTF16("a"), 1); |
| 3133 AddSearchToHistory(default_t_url_, ASCIIToUTF16("alpha"), 1); | 3298 AddSearchToHistory(default_t_url_, ASCIIToUTF16("alpha"), 1); |
| 3134 AddSearchToHistory(default_t_url_, ASCIIToUTF16("avid"), 1); | 3299 AddSearchToHistory(default_t_url_, ASCIIToUTF16("avid"), 1); |
| 3135 | 3300 |
| 3136 profile_.BlockUntilHistoryProcessesPendingRequests(); | 3301 profile_.BlockUntilHistoryProcessesPendingRequests(); |
| 3137 QueryForInput(ASCIIToUTF16("a"), false, false); | 3302 QueryForInputAndWaitForFetcherResponses( |
| 3138 | 3303 ASCIIToUTF16("a"), false, |
| 3139 // Make sure the default provider's suggest service was queried. | |
| 3140 net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID( | |
| 3141 SearchProvider::kDefaultProviderURLFetcherID); | |
| 3142 ASSERT_TRUE(fetcher); | |
| 3143 | |
| 3144 // Tell the SearchProvider the suggest query is done. | |
| 3145 fetcher->set_response_code(200); | |
| 3146 fetcher->SetResponseString( | |
| 3147 "[\"a\",[\"a\", \"alpha\", \"avid\", \"apricot\"],[],[]," | 3304 "[\"a\",[\"a\", \"alpha\", \"avid\", \"apricot\"],[],[]," |
| 3148 "{\"google:suggestrelevance\":[1450, 1200, 1150, 1100]," | 3305 "{\"google:suggestrelevance\":[1450, 1200, 1150, 1100]," |
| 3149 "\"google:verbatimrelevance\":1350}]"); | 3306 "\"google:verbatimrelevance\":1350}]", |
| 3150 fetcher->delegate()->OnURLFetchComplete(fetcher); | 3307 std::string()); |
| 3151 fetcher = NULL; | |
| 3152 | |
| 3153 // Run till the history results complete. | |
| 3154 RunTillProviderDone(); | |
| 3155 | 3308 |
| 3156 AutocompleteMatch verbatim, match_alpha, match_apricot, match_avid; | 3309 AutocompleteMatch verbatim, match_alpha, match_apricot, match_avid; |
| 3157 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a"), &verbatim)); | 3310 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("a"), &verbatim)); |
| 3158 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("alpha"), &match_alpha)); | 3311 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("alpha"), &match_alpha)); |
| 3159 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("apricot"), &match_apricot)); | 3312 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("apricot"), &match_apricot)); |
| 3160 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("avid"), &match_avid)); | 3313 EXPECT_TRUE(FindMatchWithContents(ASCIIToUTF16("avid"), &match_avid)); |
| 3161 | 3314 |
| 3162 // Verbatim match duplicates are added such that each one has a higher | 3315 // Verbatim match duplicates are added such that each one has a higher |
| 3163 // relevance than the previous one. | 3316 // relevance than the previous one. |
| 3164 EXPECT_EQ(2U, verbatim.duplicate_matches.size()); | 3317 EXPECT_EQ(2U, verbatim.duplicate_matches.size()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3260 AutocompleteInput input(base::ASCIIToUTF16("weather l"), | 3413 AutocompleteInput input(base::ASCIIToUTF16("weather l"), |
| 3261 base::string16::npos, base::string16(), GURL(), | 3414 base::string16::npos, base::string16(), GURL(), |
| 3262 metrics::OmniboxEventProto::INVALID_SPEC, false, | 3415 metrics::OmniboxEventProto::INVALID_SPEC, false, |
| 3263 false, true, true, | 3416 false, true, true, |
| 3264 ChromeAutocompleteSchemeClassifier(&profile_)); | 3417 ChromeAutocompleteSchemeClassifier(&profile_)); |
| 3265 provider_->DoAnswersQuery(input); | 3418 provider_->DoAnswersQuery(input); |
| 3266 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), | 3419 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), |
| 3267 provider_->prefetch_data_.full_query_text); | 3420 provider_->prefetch_data_.full_query_text); |
| 3268 EXPECT_EQ(base::ASCIIToUTF16("2334"), provider_->prefetch_data_.query_type); | 3421 EXPECT_EQ(base::ASCIIToUTF16("2334"), provider_->prefetch_data_.query_type); |
| 3269 } | 3422 } |
| OLD | NEW |