Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc

Issue 10828401: Add a getter for search provider logos. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed enum and other nits. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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, GetLogoURLGoogle100Percent) {
181 TemplateURLData data;
182 data.SetURL("http://www.google.com/");
183 TemplateURL turl(NULL, data);
184 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL(
185 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT);
186
187 EXPECT_EQ("www.google.com", logo_url.host());
188 EXPECT_TRUE(logo_url.SchemeIsSecure());
Peter Kasting 2012/08/28 23:20:20 Why is testing for a secure scheme something the u
samarth 2012/08/28 23:29:20 Done.
189 }
190
191 TEST(TemplateURLPrepopulateDataTest, GetLogoURLGoogle200Percent) {
Peter Kasting 2012/08/28 23:20:20 Nit: Combine these first two tests, a la: ...
samarth 2012/08/28 23:29:20 Done.
192 TemplateURLData data;
193 data.SetURL("http://www.google.com/");
194 TemplateURL turl(NULL, data);
195 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL(
196 turl, TemplateURLPrepopulateData::LOGO_200_PERCENT);
197
198 EXPECT_EQ("www.google.com", logo_url.host());
199 EXPECT_TRUE(logo_url.SchemeIsSecure());
200 }
201
202 TEST(TemplateURLPrepopulateDataTest, GetLogoURLUnknown) {
203 TemplateURLData data;
204 data.SetURL("http://webalta.ru/");
205 TemplateURL turl(NULL, data);
206 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL(
207 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT);
208
209 EXPECT_TRUE(logo_url.is_empty());
210 }
211
212 TEST(TemplateURLPrepopulateDataTest, GetLogoURLInvalid) {
213 TemplateURLData data;
214 data.SetURL("http://invalid:search:url/");
215 TemplateURL turl(NULL, data);
216 GURL logo_url = TemplateURLPrepopulateData::GetLogoURL(
217 turl, TemplateURLPrepopulateData::LOGO_100_PERCENT);
218
219 EXPECT_TRUE(logo_url.is_empty());
220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698