OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/keyword_provider.h" | 5 #include "components/omnibox/browser/keyword_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 { "aa foo", 7u, true, "aa.com?foo={searchTerms}", "foo", 3u }, | 492 { "aa foo", 7u, true, "aa.com?foo={searchTerms}", "foo", 3u }, |
493 // Extra space after keyword, no trailing space, cursor in the middle. | 493 // Extra space after keyword, no trailing space, cursor in the middle. |
494 { "aa foo", 5u, true, "aa.com?foo={searchTerms}", "foo", 1u }, | 494 { "aa foo", 5u, true, "aa.com?foo={searchTerms}", "foo", 1u }, |
495 | 495 |
496 // Disallow exact keyword match. | 496 // Disallow exact keyword match. |
497 { "aa foo", base::string16::npos, false, "", "aa foo", | 497 { "aa foo", base::string16::npos, false, "", "aa foo", |
498 base::string16::npos }, | 498 base::string16::npos }, |
499 }; | 499 }; |
500 SetUpClientAndKeywordProvider(); | 500 SetUpClientAndKeywordProvider(); |
501 for (size_t i = 0; i < arraysize(cases); i++) { | 501 for (size_t i = 0; i < arraysize(cases); i++) { |
502 AutocompleteInput input(ASCIIToUTF16(cases[i].text), | 502 AutocompleteInput input( |
503 cases[i].cursor_position, std::string(), GURL(), | 503 ASCIIToUTF16(cases[i].text), cases[i].cursor_position, std::string(), |
504 metrics::OmniboxEventProto::INVALID_SPEC, false, | 504 GURL(), base::string16(), metrics::OmniboxEventProto::INVALID_SPEC, |
505 false, cases[i].allow_exact_keyword_match, true, | 505 false, false, cases[i].allow_exact_keyword_match, true, false, |
506 false, TestingSchemeClassifier()); | 506 TestingSchemeClassifier()); |
507 const TemplateURL* url = | 507 const TemplateURL* url = |
508 KeywordProvider::GetSubstitutingTemplateURLForInput( | 508 KeywordProvider::GetSubstitutingTemplateURLForInput( |
509 client_->GetTemplateURLService(), &input); | 509 client_->GetTemplateURLService(), &input); |
510 if (cases[i].expected_url.empty()) | 510 if (cases[i].expected_url.empty()) |
511 EXPECT_FALSE(url); | 511 EXPECT_FALSE(url); |
512 else | 512 else |
513 EXPECT_EQ(cases[i].expected_url, url->url()); | 513 EXPECT_EQ(cases[i].expected_url, url->url()); |
514 EXPECT_EQ(ASCIIToUTF16(cases[i].updated_text), input.text()); | 514 EXPECT_EQ(ASCIIToUTF16(cases[i].updated_text), input.text()); |
515 EXPECT_EQ(cases[i].updated_cursor_position, input.cursor_position()); | 515 EXPECT_EQ(cases[i].updated_cursor_position, input.cursor_position()); |
516 } | 516 } |
(...skipping 13 matching lines...) Expand all Loading... |
530 }; | 530 }; |
531 | 531 |
532 SetUpClientAndKeywordProvider(); | 532 SetUpClientAndKeywordProvider(); |
533 RunTest<GURL>(url_cases, arraysize(url_cases), | 533 RunTest<GURL>(url_cases, arraysize(url_cases), |
534 &AutocompleteMatch::destination_url); | 534 &AutocompleteMatch::destination_url); |
535 } | 535 } |
536 | 536 |
537 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { | 537 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { |
538 SetUpClientAndKeywordProvider(); | 538 SetUpClientAndKeywordProvider(); |
539 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, | 539 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, |
540 std::string(), GURL(), | 540 std::string(), GURL(), base::string16(), |
541 metrics::OmniboxEventProto::INVALID_SPEC, true, false, | 541 metrics::OmniboxEventProto::INVALID_SPEC, true, false, |
542 true, true, true, TestingSchemeClassifier()); | 542 true, true, true, TestingSchemeClassifier()); |
543 kw_provider_->Start(input, false); | 543 kw_provider_->Start(input, false); |
544 ASSERT_TRUE(kw_provider_->matches().empty()); | 544 ASSERT_TRUE(kw_provider_->matches().empty()); |
545 } | 545 } |
OLD | NEW |