| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "components/metrics/proto/omnibox_event.pb.h" | 16 #include "components/metrics/proto/omnibox_event.pb.h" |
| 16 #include "components/omnibox/browser/autocomplete_match.h" | 17 #include "components/omnibox/browser/autocomplete_match.h" |
| 17 #include "components/omnibox/browser/autocomplete_scheme_classifier.h" | 18 #include "components/omnibox/browser/autocomplete_scheme_classifier.h" |
| 18 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" | 19 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" |
| 19 #include "components/omnibox/browser/omnibox_field_trial.h" | 20 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 20 #include "components/search_engines/search_engines_switches.h" | 21 #include "components/search_engines/search_engines_switches.h" |
| 21 #include "components/search_engines/template_url.h" | 22 #include "components/search_engines/template_url.h" |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 &AutocompleteMatch::contents); | 422 &AutocompleteMatch::contents); |
| 422 } | 423 } |
| 423 | 424 |
| 424 TEST_F(KeywordProviderTest, AddKeyword) { | 425 TEST_F(KeywordProviderTest, AddKeyword) { |
| 425 SetUpClientAndKeywordProvider(); | 426 SetUpClientAndKeywordProvider(); |
| 426 TemplateURLData data; | 427 TemplateURLData data; |
| 427 data.SetShortName(ASCIIToUTF16("Test")); | 428 data.SetShortName(ASCIIToUTF16("Test")); |
| 428 base::string16 keyword(ASCIIToUTF16("foo")); | 429 base::string16 keyword(ASCIIToUTF16("foo")); |
| 429 data.SetKeyword(keyword); | 430 data.SetKeyword(keyword); |
| 430 data.SetURL("http://www.google.com/foo?q={searchTerms}"); | 431 data.SetURL("http://www.google.com/foo?q={searchTerms}"); |
| 431 TemplateURL* template_url = new TemplateURL(data); | 432 TemplateURL* template_url = client_->GetTemplateURLService()->Add( |
| 432 client_->GetTemplateURLService()->Add(template_url); | 433 base::MakeUnique<TemplateURL>(data)); |
| 433 ASSERT_TRUE( | 434 ASSERT_TRUE( |
| 434 template_url == | 435 template_url == |
| 435 client_->GetTemplateURLService()->GetTemplateURLForKeyword(keyword)); | 436 client_->GetTemplateURLService()->GetTemplateURLForKeyword(keyword)); |
| 436 } | 437 } |
| 437 | 438 |
| 438 TEST_F(KeywordProviderTest, RemoveKeyword) { | 439 TEST_F(KeywordProviderTest, RemoveKeyword) { |
| 439 SetUpClientAndKeywordProvider(); | 440 SetUpClientAndKeywordProvider(); |
| 440 TemplateURLService* template_url_service = client_->GetTemplateURLService(); | 441 TemplateURLService* template_url_service = client_->GetTemplateURLService(); |
| 441 base::string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c")); | 442 base::string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c")); |
| 442 template_url_service->Remove( | 443 template_url_service->Remove( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 536 |
| 536 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { | 537 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { |
| 537 SetUpClientAndKeywordProvider(); | 538 SetUpClientAndKeywordProvider(); |
| 538 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, | 539 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, |
| 539 std::string(), GURL(), | 540 std::string(), GURL(), |
| 540 metrics::OmniboxEventProto::INVALID_SPEC, true, false, | 541 metrics::OmniboxEventProto::INVALID_SPEC, true, false, |
| 541 true, true, true, TestingSchemeClassifier()); | 542 true, true, true, TestingSchemeClassifier()); |
| 542 kw_provider_->Start(input, false); | 543 kw_provider_->Start(input, false); |
| 543 ASSERT_TRUE(kw_provider_->matches().empty()); | 544 ASSERT_TRUE(kw_provider_->matches().empty()); |
| 544 } | 545 } |
| OLD | NEW |