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 std::unique_ptr<TemplateURL> template_url_ptr = |
432 client_->GetTemplateURLService()->Add(template_url); | 433 base::MakeUnique<TemplateURL>(data); |
434 TemplateURL* template_url = template_url_ptr.get(); | |
435 client_->GetTemplateURLService()->Add(std::move(template_url_ptr)); | |
Peter Kasting
2016/08/31 04:12:56
Nit: Just use the old code and add a WrapUnique()
Avi (use Gerrit)
2016/09/01 00:34:26
Done.
| |
433 ASSERT_TRUE( | 436 ASSERT_TRUE( |
434 template_url == | 437 template_url == |
435 client_->GetTemplateURLService()->GetTemplateURLForKeyword(keyword)); | 438 client_->GetTemplateURLService()->GetTemplateURLForKeyword(keyword)); |
436 } | 439 } |
437 | 440 |
438 TEST_F(KeywordProviderTest, RemoveKeyword) { | 441 TEST_F(KeywordProviderTest, RemoveKeyword) { |
439 SetUpClientAndKeywordProvider(); | 442 SetUpClientAndKeywordProvider(); |
440 TemplateURLService* template_url_service = client_->GetTemplateURLService(); | 443 TemplateURLService* template_url_service = client_->GetTemplateURLService(); |
441 base::string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c")); | 444 base::string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c")); |
442 template_url_service->Remove( | 445 template_url_service->Remove( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 | 538 |
536 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { | 539 TEST_F(KeywordProviderTest, DoesNotProvideMatchesOnFocus) { |
537 SetUpClientAndKeywordProvider(); | 540 SetUpClientAndKeywordProvider(); |
538 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, | 541 AutocompleteInput input(ASCIIToUTF16("aaa"), base::string16::npos, |
539 std::string(), GURL(), | 542 std::string(), GURL(), |
540 metrics::OmniboxEventProto::INVALID_SPEC, true, false, | 543 metrics::OmniboxEventProto::INVALID_SPEC, true, false, |
541 true, true, true, TestingSchemeClassifier()); | 544 true, true, true, TestingSchemeClassifier()); |
542 kw_provider_->Start(input, false); | 545 kw_provider_->Start(input, false); |
543 ASSERT_TRUE(kw_provider_->matches().empty()); | 546 ASSERT_TRUE(kw_provider_->matches().empty()); |
544 } | 547 } |
OLD | NEW |