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

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

Issue 10535125: Move the query to the start of the Google search URL in hopes of being slightly more user-friendly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « chrome/browser/search_engines/template_url_prepopulate_data.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 ASSERT_EQ(1u, t_urls.size()); 120 ASSERT_EQ(1u, t_urls.size());
121 EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name()); 121 EXPECT_EQ(ASCIIToUTF16("foo"), t_urls[0]->short_name());
122 EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword()); 122 EXPECT_EQ(ASCIIToUTF16("fook"), t_urls[0]->keyword());
123 EXPECT_EQ("foo.com", t_urls[0]->url_ref().GetHost()); 123 EXPECT_EQ("foo.com", t_urls[0]->url_ref().GetHost());
124 EXPECT_EQ("foi.com", t_urls[0]->favicon_url().host()); 124 EXPECT_EQ("foi.com", t_urls[0]->favicon_url().host());
125 EXPECT_EQ(1u, t_urls[0]->input_encodings().size()); 125 EXPECT_EQ(1u, t_urls[0]->input_encodings().size());
126 EXPECT_EQ(1001, t_urls[0]->prepopulate_id()); 126 EXPECT_EQ(1001, t_urls[0]->prepopulate_id());
127 } 127 }
128 128
129 TEST(TemplateURLPrepopulateDataTest, GetEngineName) {
130 EXPECT_EQ(ASCIIToUTF16("Atlas"),
131 TemplateURLPrepopulateData::GetEngineName("http://search.atlas.cz/"));
132 EXPECT_EQ(ASCIIToUTF16("Google"),
133 TemplateURLPrepopulateData::GetEngineName("http://www.google.com/"));
134 EXPECT_EQ(ASCIIToUTF16("example.com"),
135 TemplateURLPrepopulateData::GetEngineName("http://example.com/"));
136 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_UNKNOWN_SEARCH_ENGINE_NAME),
137 TemplateURLPrepopulateData::GetEngineName("!@#"));
138 }
139
140 TEST(TemplateURLPrepopulateDataTest, GetEngineTypeBasic) { 129 TEST(TemplateURLPrepopulateDataTest, GetEngineTypeBasic) {
141 EXPECT_EQ(SEARCH_ENGINE_OTHER, 130 EXPECT_EQ(SEARCH_ENGINE_OTHER,
142 TemplateURLPrepopulateData::GetEngineType("http://example.com/")); 131 TemplateURLPrepopulateData::GetEngineType("http://example.com/"));
143 EXPECT_EQ(SEARCH_ENGINE_ASK, 132 EXPECT_EQ(SEARCH_ENGINE_ASK,
144 TemplateURLPrepopulateData::GetEngineType("http://www.ask.com/")); 133 TemplateURLPrepopulateData::GetEngineType("http://www.ask.com/"));
145 EXPECT_EQ(SEARCH_ENGINE_OTHER, 134 EXPECT_EQ(SEARCH_ENGINE_OTHER,
146 TemplateURLPrepopulateData::GetEngineType("http://search.atlas.cz/")); 135 TemplateURLPrepopulateData::GetEngineType("http://search.atlas.cz/"));
147 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, 136 EXPECT_EQ(SEARCH_ENGINE_GOOGLE,
148 TemplateURLPrepopulateData::GetEngineType("http://www.google.com/")); 137 TemplateURLPrepopulateData::GetEngineType("http://www.google.com/"));
149 } 138 }
150 139
151 TEST_F(TemplateURLPrepopulateDataTest, GetEngineTypeAdvanced) { 140 TEST_F(TemplateURLPrepopulateDataTest, GetEngineTypeAdvanced) {
152 // Google URLs in different forms. 141 // Google URLs in different forms.
153 const char* kGoogleURLs[] = { 142 const char* kGoogleURLs[] = {
154 // Original with google:baseURL: 143 // Original with google:baseURL:
155 "{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}" 144 "{google:baseURL}search?q={searchTerms}&{google:RLZ}"
156 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" 145 "{google:acceptedSuggestion}{google:originalQueryForSuggestion}"
157 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}", 146 "{google:searchFieldtrialParameter}sourceid=chrome&ie={inputEncoding}",
158 // Custom with google.com: 147 // Custom with google.com and reordered query params:
159 "http://google.com/search?{google:RLZ}{google:acceptedSuggestion}" 148 "http://google.com/search?{google:RLZ}{google:acceptedSuggestion}"
160 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" 149 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}"
161 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}", 150 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}",
162 // Custom with a country TLD: 151 // Custom with a country TLD and almost no query params:
163 "http://www.google.ru/search?{google:RLZ}{google:acceptedSuggestion}" 152 "http://www.google.ru/search?q={searchTerms}"
164 "{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}"
165 "sourceid=chrome&ie={inputEncoding}&q={searchTerms}"
166 }; 153 };
167 for (size_t i = 0; i < arraysize(kGoogleURLs); ++i) { 154 for (size_t i = 0; i < arraysize(kGoogleURLs); ++i) {
168 EXPECT_EQ(SEARCH_ENGINE_GOOGLE, 155 EXPECT_EQ(SEARCH_ENGINE_GOOGLE,
169 TemplateURLPrepopulateData::GetEngineType(kGoogleURLs[i])); 156 TemplateURLPrepopulateData::GetEngineType(kGoogleURLs[i]));
170 } 157 }
171 // Non-Google URLs. 158 // Non-Google URLs.
172 const char* kYahooURLs[] = { 159 const char* kYahooURLs[] = {
173 "http://search.yahoo.com/search?" 160 "http://search.yahoo.com/search?"
174 "ei={inputEncoding}&fr=crmas&p={searchTerms}", 161 "ei={inputEncoding}&fr=crmas&p={searchTerms}",
175 "http://search.yahoo.com/search?p={searchTerms}" 162 "http://search.yahoo.com/search?p={searchTerms}"
176 }; 163 };
177 for (size_t i = 0; i < arraysize(kYahooURLs); ++i) { 164 for (size_t i = 0; i < arraysize(kYahooURLs); ++i) {
178 EXPECT_EQ(SEARCH_ENGINE_YAHOO, 165 EXPECT_EQ(SEARCH_ENGINE_YAHOO,
179 TemplateURLPrepopulateData::GetEngineType(kYahooURLs[i])); 166 TemplateURLPrepopulateData::GetEngineType(kYahooURLs[i]));
180 } 167 }
181 // URLs for engines not present in country-specific lists. 168 // URLs for engines not present in country-specific lists.
182 std::string kNigmaURL = "http://www.nigma.ru/?s={searchTerms}&arg1=value1"; 169 std::string kNigmaURL = "http://www.nigma.ru/?s={searchTerms}&arg1=value1";
183 EXPECT_EQ(SEARCH_ENGINE_NIGMA, 170 EXPECT_EQ(SEARCH_ENGINE_NIGMA,
184 TemplateURLPrepopulateData::GetEngineType(kNigmaURL)); 171 TemplateURLPrepopulateData::GetEngineType(kNigmaURL));
185 // Search URL for which no prepopulated search provider exists. 172 // Search URL for which no prepopulated search provider exists.
186 std::string kExampleSearchURL = "http://example.net/search?q={searchTerms}"; 173 std::string kExampleSearchURL = "http://example.net/search?q={searchTerms}";
187 EXPECT_EQ(SEARCH_ENGINE_OTHER, 174 EXPECT_EQ(SEARCH_ENGINE_OTHER,
188 TemplateURLPrepopulateData::GetEngineType(kExampleSearchURL)); 175 TemplateURLPrepopulateData::GetEngineType(kExampleSearchURL));
189 EXPECT_EQ(SEARCH_ENGINE_OTHER, 176 EXPECT_EQ(SEARCH_ENGINE_OTHER,
190 TemplateURLPrepopulateData::GetEngineType("invalid:search:url")); 177 TemplateURLPrepopulateData::GetEngineType("invalid:search:url"));
191 } 178 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_prepopulate_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698