OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/search_provider.h" | 5 #include "components/omnibox/search_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 TemplateURLServiceFactory::GetForProfile(&profile_); | 1152 TemplateURLServiceFactory::GetForProfile(&profile_); |
1153 | 1153 |
1154 TemplateURLData data; | 1154 TemplateURLData data; |
1155 data.short_name = ASCIIToUTF16("default"); | 1155 data.short_name = ASCIIToUTF16("default"); |
1156 data.SetKeyword(data.short_name); | 1156 data.SetKeyword(data.short_name); |
1157 data.SetURL("{google:baseURL}{searchTerms}"); | 1157 data.SetURL("{google:baseURL}{searchTerms}"); |
1158 default_t_url_ = new TemplateURL(data); | 1158 default_t_url_ = new TemplateURL(data); |
1159 turl_model->Add(default_t_url_); | 1159 turl_model->Add(default_t_url_); |
1160 turl_model->SetUserSelectedDefaultSearchProvider(default_t_url_); | 1160 turl_model->SetUserSelectedDefaultSearchProvider(default_t_url_); |
1161 | 1161 |
1162 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kGoogleBaseURL, | 1162 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
1163 "http://www.bar.com/"); | 1163 switches::kGoogleBaseURL, "http://www.bar.com/"); |
1164 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 1164 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
1165 switches::kExtraSearchQueryParams, "a=b"); | 1165 switches::kExtraSearchQueryParams, "a=b"); |
1166 | 1166 |
1167 TestData cases[] = { | 1167 TestData cases[] = { |
1168 { ASCIIToUTF16("k a"), 2, | 1168 { ASCIIToUTF16("k a"), 2, |
1169 { ResultInfo(GURL("http://keyword/a"), | 1169 { ResultInfo(GURL("http://keyword/a"), |
1170 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 1170 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
1171 true, | 1171 true, |
1172 ASCIIToUTF16("k a")), | 1172 ASCIIToUTF16("k a")), |
1173 ResultInfo(GURL("http://www.bar.com/k%20a?a=b"), | 1173 ResultInfo(GURL("http://www.bar.com/k%20a?a=b"), |
1174 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 1174 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3318 EXPECT_EQ(2U, verbatim.duplicate_matches.size()); | 3318 EXPECT_EQ(2U, verbatim.duplicate_matches.size()); |
3319 | 3319 |
3320 // Other match duplicates are added in descending relevance order. | 3320 // Other match duplicates are added in descending relevance order. |
3321 EXPECT_EQ(1U, match_alpha.duplicate_matches.size()); | 3321 EXPECT_EQ(1U, match_alpha.duplicate_matches.size()); |
3322 EXPECT_EQ(1U, match_avid.duplicate_matches.size()); | 3322 EXPECT_EQ(1U, match_avid.duplicate_matches.size()); |
3323 | 3323 |
3324 EXPECT_EQ(0U, match_apricot.duplicate_matches.size()); | 3324 EXPECT_EQ(0U, match_apricot.duplicate_matches.size()); |
3325 } | 3325 } |
3326 | 3326 |
3327 TEST_F(SearchProviderTest, SuggestQueryUsesToken) { | 3327 TEST_F(SearchProviderTest, SuggestQueryUsesToken) { |
3328 CommandLine::ForCurrentProcess()->AppendSwitch( | 3328 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
3329 switches::kEnableAnswersInSuggest); | 3329 switches::kEnableAnswersInSuggest); |
3330 | 3330 |
3331 TemplateURLService* turl_model = | 3331 TemplateURLService* turl_model = |
3332 TemplateURLServiceFactory::GetForProfile(&profile_); | 3332 TemplateURLServiceFactory::GetForProfile(&profile_); |
3333 | 3333 |
3334 TemplateURLData data; | 3334 TemplateURLData data; |
3335 data.short_name = ASCIIToUTF16("default"); | 3335 data.short_name = ASCIIToUTF16("default"); |
3336 data.SetKeyword(data.short_name); | 3336 data.SetKeyword(data.short_name); |
3337 data.SetURL("http://example/{searchTerms}{google:sessionToken}"); | 3337 data.SetURL("http://example/{searchTerms}{google:sessionToken}"); |
3338 data.suggestions_url = | 3338 data.suggestions_url = |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3464 EXPECT_TRUE(matches[2].answer_contents.empty()); | 3464 EXPECT_TRUE(matches[2].answer_contents.empty()); |
3465 EXPECT_TRUE(matches[2].answer_type.empty()); | 3465 EXPECT_TRUE(matches[2].answer_type.empty()); |
3466 EXPECT_FALSE(matches[2].answer); | 3466 EXPECT_FALSE(matches[2].answer); |
3467 EXPECT_TRUE(matches[3].answer_contents.empty()); | 3467 EXPECT_TRUE(matches[3].answer_contents.empty()); |
3468 EXPECT_TRUE(matches[3].answer_type.empty()); | 3468 EXPECT_TRUE(matches[3].answer_type.empty()); |
3469 EXPECT_FALSE(matches[3].answer); | 3469 EXPECT_FALSE(matches[3].answer); |
3470 EXPECT_TRUE(matches[4].answer_contents.empty()); | 3470 EXPECT_TRUE(matches[4].answer_contents.empty()); |
3471 EXPECT_TRUE(matches[4].answer_type.empty()); | 3471 EXPECT_TRUE(matches[4].answer_type.empty()); |
3472 EXPECT_FALSE(matches[4].answer); | 3472 EXPECT_FALSE(matches[4].answer); |
3473 } | 3473 } |
OLD | NEW |