| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 std::string kNigmaURL = "http://www.nigma.ru/?s={searchTerms}&arg1=value1"; | 169 std::string kNigmaURL = "http://www.nigma.ru/?s={searchTerms}&arg1=value1"; |
| 170 EXPECT_EQ(SEARCH_ENGINE_NIGMA, | 170 EXPECT_EQ(SEARCH_ENGINE_NIGMA, |
| 171 TemplateURLPrepopulateData::GetEngineType(kNigmaURL)); | 171 TemplateURLPrepopulateData::GetEngineType(kNigmaURL)); |
| 172 // Search URL for which no prepopulated search provider exists. | 172 // Search URL for which no prepopulated search provider exists. |
| 173 std::string kExampleSearchURL = "http://example.net/search?q={searchTerms}"; | 173 std::string kExampleSearchURL = "http://example.net/search?q={searchTerms}"; |
| 174 EXPECT_EQ(SEARCH_ENGINE_OTHER, | 174 EXPECT_EQ(SEARCH_ENGINE_OTHER, |
| 175 TemplateURLPrepopulateData::GetEngineType(kExampleSearchURL)); | 175 TemplateURLPrepopulateData::GetEngineType(kExampleSearchURL)); |
| 176 EXPECT_EQ(SEARCH_ENGINE_OTHER, | 176 EXPECT_EQ(SEARCH_ENGINE_OTHER, |
| 177 TemplateURLPrepopulateData::GetEngineType("invalid:search:url")); | 177 TemplateURLPrepopulateData::GetEngineType("invalid:search:url")); |
| 178 } | 178 } |
| 179 |
| 180 TEST(TemplateURLPrepopulateDataTest, GetLogoURLGoogle) { |
| 181 TemplateURLData data; |
| 182 data.SetURL("http://www.google.com/"); |
| 183 TemplateURL turl(NULL, data); |
| 184 GURL logo_100_url = TemplateURLPrepopulateData::GetLogoURL( |
| 185 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT); |
| 186 GURL logo_200_url = TemplateURLPrepopulateData::GetLogoURL( |
| 187 turl, TemplateURLPrepopulateData::LOGO_200_PERCENT); |
| 188 |
| 189 EXPECT_EQ("www.google.com", logo_100_url.host()); |
| 190 EXPECT_EQ("www.google.com", logo_200_url.host()); |
| 191 EXPECT_NE(logo_100_url, logo_200_url); |
| 192 } |
| 193 |
| 194 TEST(TemplateURLPrepopulateDataTest, GetLogoURLUnknown) { |
| 195 TemplateURLData data; |
| 196 data.SetURL("http://webalta.ru/"); |
| 197 TemplateURL turl(NULL, data); |
| 198 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL( |
| 199 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT); |
| 200 |
| 201 EXPECT_TRUE(logo_url.is_empty()); |
| 202 } |
| 203 |
| 204 TEST(TemplateURLPrepopulateDataTest, GetLogoURLInvalid) { |
| 205 TemplateURLData data; |
| 206 data.SetURL("http://invalid:search:url/"); |
| 207 TemplateURL turl(NULL, data); |
| 208 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL( |
| 209 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT); |
| 210 |
| 211 EXPECT_TRUE(logo_url.is_empty()); |
| 212 } |
| OLD | NEW |