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/base_search_provider.h" | 5 #include "components/omnibox/browser/base_search_provider.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
10 #include "components/omnibox/browser/autocomplete_match.h" | 12 #include "components/omnibox/browser/autocomplete_match.h" |
11 #include "components/omnibox/browser/autocomplete_match_type.h" | 13 #include "components/omnibox/browser/autocomplete_match_type.h" |
12 #include "components/omnibox/browser/autocomplete_scheme_classifier.h" | 14 #include "components/omnibox/browser/autocomplete_scheme_classifier.h" |
13 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" | 15 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" |
14 #include "components/omnibox/browser/search_suggestion_parser.h" | 16 #include "components/omnibox/browser/search_suggestion_parser.h" |
15 #include "components/omnibox/browser/suggestion_answer.h" | 17 #include "components/omnibox/browser/suggestion_answer.h" |
16 #include "components/search_engines/search_terms_data.h" | 18 #include "components/search_engines/search_terms_data.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 public: | 67 public: |
66 ~BaseSearchProviderTest() override {} | 68 ~BaseSearchProviderTest() override {} |
67 | 69 |
68 protected: | 70 protected: |
69 void SetUp() override { | 71 void SetUp() override { |
70 scoped_ptr<TemplateURLService> template_url_service(new TemplateURLService( | 72 scoped_ptr<TemplateURLService> template_url_service(new TemplateURLService( |
71 nullptr, scoped_ptr<SearchTermsData>(new SearchTermsData), nullptr, | 73 nullptr, scoped_ptr<SearchTermsData>(new SearchTermsData), nullptr, |
72 scoped_ptr<TemplateURLServiceClient>(), nullptr, nullptr, | 74 scoped_ptr<TemplateURLServiceClient>(), nullptr, nullptr, |
73 base::Closure())); | 75 base::Closure())); |
74 client_.reset(new NiceMock<MockAutocompleteProviderClient>()); | 76 client_.reset(new NiceMock<MockAutocompleteProviderClient>()); |
75 client_->set_template_url_service(template_url_service.Pass()); | 77 client_->set_template_url_service(std::move(template_url_service)); |
76 provider_ = new NiceMock<TestBaseSearchProvider>( | 78 provider_ = new NiceMock<TestBaseSearchProvider>( |
77 AutocompleteProvider::TYPE_SEARCH, client_.get()); | 79 AutocompleteProvider::TYPE_SEARCH, client_.get()); |
78 } | 80 } |
79 | 81 |
80 scoped_refptr<NiceMock<TestBaseSearchProvider> > provider_; | 82 scoped_refptr<NiceMock<TestBaseSearchProvider> > provider_; |
81 scoped_ptr<NiceMock<MockAutocompleteProviderClient>> client_; | 83 scoped_ptr<NiceMock<MockAutocompleteProviderClient>> client_; |
82 }; | 84 }; |
83 | 85 |
84 TEST_F(BaseSearchProviderTest, PreserveAnswersWhenDeduplicating) { | 86 TEST_F(BaseSearchProviderTest, PreserveAnswersWhenDeduplicating) { |
85 TemplateURLData data; | 87 TemplateURLData data; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 EXPECT_TRUE(answer2->Equals(*match.answer)); | 161 EXPECT_TRUE(answer2->Equals(*match.answer)); |
160 EXPECT_EQ(AutocompleteMatchType::SEARCH_HISTORY, match.type); | 162 EXPECT_EQ(AutocompleteMatchType::SEARCH_HISTORY, match.type); |
161 EXPECT_EQ(1300, match.relevance); | 163 EXPECT_EQ(1300, match.relevance); |
162 | 164 |
163 EXPECT_EQ(answer_contents, duplicate.answer_contents); | 165 EXPECT_EQ(answer_contents, duplicate.answer_contents); |
164 EXPECT_EQ(answer_type, duplicate.answer_type); | 166 EXPECT_EQ(answer_type, duplicate.answer_type); |
165 EXPECT_TRUE(answer->Equals(*duplicate.answer)); | 167 EXPECT_TRUE(answer->Equals(*duplicate.answer)); |
166 EXPECT_EQ(AutocompleteMatchType::SEARCH_SUGGEST, duplicate.type); | 168 EXPECT_EQ(AutocompleteMatchType::SEARCH_SUGGEST, duplicate.type); |
167 EXPECT_EQ(850, duplicate.relevance); | 169 EXPECT_EQ(850, duplicate.relevance); |
168 } | 170 } |
OLD | NEW |