| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/omnibox/browser/autocomplete_provider.h" | 5 #include "components/omnibox/browser/autocomplete_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 AutocompleteMatch match; | 436 AutocompleteMatch match; |
| 437 match.relevance = 1000; // Arbitrary non-zero value. | 437 match.relevance = 1000; // Arbitrary non-zero value. |
| 438 match.allowed_to_be_default_match = true; | 438 match.allowed_to_be_default_match = true; |
| 439 match.fill_into_edit = match_data[i].fill_into_edit; | 439 match.fill_into_edit = match_data[i].fill_into_edit; |
| 440 match.transition = ui::PAGE_TRANSITION_KEYWORD; | 440 match.transition = ui::PAGE_TRANSITION_KEYWORD; |
| 441 match.keyword = match_data[i].keyword; | 441 match.keyword = match_data[i].keyword; |
| 442 matches.push_back(match); | 442 matches.push_back(match); |
| 443 } | 443 } |
| 444 | 444 |
| 445 controller_->input_ = AutocompleteInput( | 445 controller_->input_ = AutocompleteInput( |
| 446 input, base::string16::npos, std::string(), GURL(), | 446 input, base::string16::npos, std::string(), GURL(), base::string16(), |
| 447 metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS, | 447 metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS, |
| 448 false, true, true, true, false, TestingSchemeClassifier()); | 448 false, true, true, true, false, TestingSchemeClassifier()); |
| 449 AutocompleteResult result; | 449 AutocompleteResult result; |
| 450 result.AppendMatches(controller_->input_, matches); | 450 result.AppendMatches(controller_->input_, matches); |
| 451 controller_->UpdateAssociatedKeywords(&result); | 451 controller_->UpdateAssociatedKeywords(&result); |
| 452 for (size_t j = 0; j < result.size(); ++j) { | 452 for (size_t j = 0; j < result.size(); ++j) { |
| 453 EXPECT_EQ(match_data[j].expected_associated_keyword, | 453 EXPECT_EQ(match_data[j].expected_associated_keyword, |
| 454 result.match_at(j)->associated_keyword.get() | 454 result.match_at(j)->associated_keyword.get() |
| 455 ? result.match_at(j)->associated_keyword->keyword | 455 ? result.match_at(j)->associated_keyword->keyword |
| 456 : base::string16()); | 456 : base::string16()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 483 EXPECT_EQ(aqs_test_data[i].expected_aqs, | 483 EXPECT_EQ(aqs_test_data[i].expected_aqs, |
| 484 result_.match_at(i)->search_terms_args->assisted_query_stats); | 484 result_.match_at(i)->search_terms_args->assisted_query_stats); |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 | 487 |
| 488 void AutocompleteProviderTest::RunQuery(const std::string& query, | 488 void AutocompleteProviderTest::RunQuery(const std::string& query, |
| 489 bool allow_exact_keyword_match) { | 489 bool allow_exact_keyword_match) { |
| 490 result_.Reset(); | 490 result_.Reset(); |
| 491 controller_->Start(AutocompleteInput( | 491 controller_->Start(AutocompleteInput( |
| 492 base::ASCIIToUTF16(query), base::string16::npos, std::string(), GURL(), | 492 base::ASCIIToUTF16(query), base::string16::npos, std::string(), GURL(), |
| 493 metrics::OmniboxEventProto::INVALID_SPEC, true, false, | 493 base::string16(), metrics::OmniboxEventProto::INVALID_SPEC, true, false, |
| 494 allow_exact_keyword_match, true, false, TestingSchemeClassifier())); | 494 allow_exact_keyword_match, true, false, TestingSchemeClassifier())); |
| 495 | 495 |
| 496 if (!controller_->done()) | 496 if (!controller_->done()) |
| 497 // The message loop will terminate when all autocomplete input has been | 497 // The message loop will terminate when all autocomplete input has been |
| 498 // collected. | 498 // collected. |
| 499 base::RunLoop().Run(); | 499 base::RunLoop().Run(); |
| 500 } | 500 } |
| 501 | 501 |
| 502 void AutocompleteProviderTest::RunExactKeymatchTest( | 502 void AutocompleteProviderTest::RunExactKeymatchTest( |
| 503 bool allow_exact_keyword_match) { | 503 bool allow_exact_keyword_match) { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 EXPECT_FALSE(search_provider_field_trial_triggered_in_session()); | 764 EXPECT_FALSE(search_provider_field_trial_triggered_in_session()); |
| 765 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 765 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 766 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); | 766 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); |
| 767 | 767 |
| 768 // Test page classification and field trial triggered set. | 768 // Test page classification and field trial triggered set. |
| 769 set_search_provider_field_trial_triggered_in_session(true); | 769 set_search_provider_field_trial_triggered_in_session(true); |
| 770 EXPECT_TRUE(search_provider_field_trial_triggered_in_session()); | 770 EXPECT_TRUE(search_provider_field_trial_triggered_in_session()); |
| 771 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 771 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 772 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); | 772 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); |
| 773 } | 773 } |
| OLD | NEW |