| 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/base_search_provider.h" | 5 #include "components/omnibox/base_search_provider.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/omnibox/autocomplete_match.h" | 9 #include "components/omnibox/autocomplete_match.h" |
| 10 #include "components/omnibox/autocomplete_match_type.h" | 10 #include "components/omnibox/autocomplete_match_type.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 AutocompleteProvider::TYPE_SEARCH); | 111 AutocompleteProvider::TYPE_SEARCH); |
| 112 } | 112 } |
| 113 | 113 |
| 114 scoped_refptr<NiceMock<TestBaseSearchProvider> > provider_; | 114 scoped_refptr<NiceMock<TestBaseSearchProvider> > provider_; |
| 115 scoped_ptr<TemplateURLService> service_; | 115 scoped_ptr<TemplateURLService> service_; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 TEST_F(BaseSearchProviderTest, PreserveAnswersWhenDeduplicating) { | 118 TEST_F(BaseSearchProviderTest, PreserveAnswersWhenDeduplicating) { |
| 119 TemplateURLData data; | 119 TemplateURLData data; |
| 120 data.SetURL("http://foo.com/url?bar={searchTerms}"); | 120 data.SetURL("http://foo.com/url?bar={searchTerms}"); |
| 121 TemplateURL* template_url = new TemplateURL(data); | 121 scoped_ptr<TemplateURL> template_url(new TemplateURL(data)); |
| 122 | 122 |
| 123 TestBaseSearchProvider::MatchMap map; | 123 TestBaseSearchProvider::MatchMap map; |
| 124 base::string16 query = base::ASCIIToUTF16("weather los angeles"); | 124 base::string16 query = base::ASCIIToUTF16("weather los angeles"); |
| 125 base::string16 answer_contents = base::ASCIIToUTF16("some answer content"); | 125 base::string16 answer_contents = base::ASCIIToUTF16("some answer content"); |
| 126 base::string16 answer_type = base::ASCIIToUTF16("2334"); | 126 base::string16 answer_type = base::ASCIIToUTF16("2334"); |
| 127 | 127 |
| 128 EXPECT_CALL(*provider_, GetInput(_)) | 128 EXPECT_CALL(*provider_, GetInput(_)) |
| 129 .WillRepeatedly(Return(AutocompleteInput())); | 129 .WillRepeatedly(Return(AutocompleteInput())); |
| 130 EXPECT_CALL(*provider_, GetTemplateURL(_)) | 130 EXPECT_CALL(*provider_, GetTemplateURL(_)) |
| 131 .WillRepeatedly(Return(template_url)); | 131 .WillRepeatedly(Return(template_url.get())); |
| 132 | 132 |
| 133 SearchSuggestionParser::SuggestResult more_relevant( | 133 SearchSuggestionParser::SuggestResult more_relevant( |
| 134 query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(), | 134 query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(), |
| 135 base::string16(), base::string16(), base::string16(), std::string(), | 135 base::string16(), base::string16(), base::string16(), std::string(), |
| 136 std::string(), false, 1300, true, false, query); | 136 std::string(), false, 1300, true, false, query); |
| 137 provider_->AddMatchToMap( | 137 provider_->AddMatchToMap( |
| 138 more_relevant, std::string(), TemplateURLRef::NO_SUGGESTION_CHOSEN, | 138 more_relevant, std::string(), TemplateURLRef::NO_SUGGESTION_CHOSEN, |
| 139 false, false, &map); | 139 false, false, &map); |
| 140 | 140 |
| 141 SearchSuggestionParser::SuggestResult less_relevant( | 141 SearchSuggestionParser::SuggestResult less_relevant( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 EXPECT_EQ(answer_type, match.answer_type); | 183 EXPECT_EQ(answer_type, match.answer_type); |
| 184 EXPECT_EQ(AutocompleteMatchType::SEARCH_HISTORY, match.type); | 184 EXPECT_EQ(AutocompleteMatchType::SEARCH_HISTORY, match.type); |
| 185 EXPECT_EQ(1300, match.relevance); | 185 EXPECT_EQ(1300, match.relevance); |
| 186 | 186 |
| 187 EXPECT_EQ(answer_contents, duplicate.answer_contents); | 187 EXPECT_EQ(answer_contents, duplicate.answer_contents); |
| 188 EXPECT_EQ(answer_type, duplicate.answer_type); | 188 EXPECT_EQ(answer_type, duplicate.answer_type); |
| 189 EXPECT_EQ(AutocompleteMatchType::SEARCH_SUGGEST, duplicate.type); | 189 EXPECT_EQ(AutocompleteMatchType::SEARCH_SUGGEST, duplicate.type); |
| 190 EXPECT_EQ(850, duplicate.relevance); | 190 EXPECT_EQ(850, duplicate.relevance); |
| 191 | 191 |
| 192 } | 192 } |
| OLD | NEW |