| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
| 7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/search_engines/search_terms_data.h" | 9 #include "chrome/browser/search_engines/search_terms_data.h" |
| 10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, | 147 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, |
| 148 TemplateURLPrepopulateData::GetEngineType("http://www.google.com/")); | 148 TemplateURLPrepopulateData::GetEngineType("http://www.google.com/")); |
| 149 } | 149 } |
| 150 | 150 |
| 151 TEST_F(TemplateURLPrepopulateDataTest, GetEngineTypeAdvanced) { | 151 TEST_F(TemplateURLPrepopulateDataTest, GetEngineTypeAdvanced) { |
| 152 // Google URLs in different forms. | 152 // Google URLs in different forms. |
| 153 const char* kGoogleURLs[] = { | 153 const char* kGoogleURLs[] = { |
| 154 // Original with google:baseURL: | 154 // Original with google:baseURL: |
| 155 "{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}" | 155 "{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}" |
| 156 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" | 156 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" |
| 157 "{google:instantFieldTrialGroupParameter}" | |
| 158 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}", | 157 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}", |
| 159 // Custom with google.com: | 158 // Custom with google.com: |
| 160 "http://google.com/search?{google:RLZ}{google:acceptedSuggestion}" | 159 "http://google.com/search?{google:RLZ}{google:acceptedSuggestion}" |
| 161 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" | 160 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" |
| 162 "{google:instantFieldTrialGroupParameter}" | |
| 163 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}", | 161 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}", |
| 164 // Custom with a country TLD: | 162 // Custom with a country TLD: |
| 165 "http://www.google.ru/search?{google:RLZ}{google:acceptedSuggestion}" | 163 "http://www.google.ru/search?{google:RLZ}{google:acceptedSuggestion}" |
| 166 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" | 164 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" |
| 167 "{google:instantFieldTrialGroupParameter}" | |
| 168 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}" | 165 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}" |
| 169 }; | 166 }; |
| 170 for (size_t i = 0; i < arraysize(kGoogleURLs); ++i) { | 167 for (size_t i = 0; i < arraysize(kGoogleURLs); ++i) { |
| 171 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, | 168 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, |
| 172 TemplateURLPrepopulateData::GetEngineType(kGoogleURLs[i])); | 169 TemplateURLPrepopulateData::GetEngineType(kGoogleURLs[i])); |
| 173 } | 170 } |
| 174 // Non-Google URLs. | 171 // Non-Google URLs. |
| 175 const char* kYahooURLs[] = { | 172 const char* kYahooURLs[] = { |
| 176 "http://search.yahoo.com/search?" | 173 "http://search.yahoo.com/search?" |
| 177 "ei={inputEncoding}&fr=crmas&p={searchTerms}", | 174 "ei={inputEncoding}&fr=crmas&p={searchTerms}", |
| 178 "http://search.yahoo.com/search?p={searchTerms}" | 175 "http://search.yahoo.com/search?p={searchTerms}" |
| 179 }; | 176 }; |
| 180 for (size_t i = 0; i < arraysize(kYahooURLs); ++i) { | 177 for (size_t i = 0; i < arraysize(kYahooURLs); ++i) { |
| 181 EXPECT_EQ(SEARCH_ENGINE_YAHOO, | 178 EXPECT_EQ(SEARCH_ENGINE_YAHOO, |
| 182 TemplateURLPrepopulateData::GetEngineType(kYahooURLs[i])); | 179 TemplateURLPrepopulateData::GetEngineType(kYahooURLs[i])); |
| 183 } | 180 } |
| 184 // Search URL for which no prepopulated search provider exists. | 181 // Search URL for which no prepopulated search provider exists. |
| 185 std::string kExampleSearchURL = "http://example.net/search?q={searchTerms}"; | 182 std::string kExampleSearchURL = "http://example.net/search?q={searchTerms}"; |
| 186 EXPECT_EQ(SEARCH_ENGINE_OTHER, | 183 EXPECT_EQ(SEARCH_ENGINE_OTHER, |
| 187 TemplateURLPrepopulateData::GetEngineType(kExampleSearchURL)); | 184 TemplateURLPrepopulateData::GetEngineType(kExampleSearchURL)); |
| 188 EXPECT_EQ(SEARCH_ENGINE_OTHER, | 185 EXPECT_EQ(SEARCH_ENGINE_OTHER, |
| 189 TemplateURLPrepopulateData::GetEngineType("invalid:search:url")); | 186 TemplateURLPrepopulateData::GetEngineType("invalid:search:url")); |
| 190 } | 187 } |
| OLD | NEW |