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/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/rlz/rlz.h" | 10 #include "chrome/browser/rlz/rlz.h" |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1161 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 1161 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
1162 switches::kExtraSearchQueryParams, "a=b"); | 1162 switches::kExtraSearchQueryParams, "a=b"); |
1163 EXPECT_EQ("http://www.google.com/search?a=b&q=abc#oq=def&x", | 1163 EXPECT_EQ("http://www.google.com/search?a=b&q=abc#oq=def&x", |
1164 url.url_ref().ReplaceSearchTerms(search_terms)); | 1164 url.url_ref().ReplaceSearchTerms(search_terms)); |
1165 | 1165 |
1166 // Turn off the flag. Now the command-line arg should be ignored again. | 1166 // Turn off the flag. Now the command-line arg should be ignored again. |
1167 search_terms.append_extra_query_params = false; | 1167 search_terms.append_extra_query_params = false; |
1168 EXPECT_EQ("http://www.google.com/search?q=abc#oq=def&x", | 1168 EXPECT_EQ("http://www.google.com/search?q=abc#oq=def&x", |
1169 url.url_ref().ReplaceSearchTerms(search_terms)); | 1169 url.url_ref().ReplaceSearchTerms(search_terms)); |
1170 } | 1170 } |
1171 | |
1172 // Test the IsSearchResults function. | |
1173 TEST_F(TemplateURLTest, IsSearchResults) { | |
1174 TemplateURLData data; | |
1175 data.SetURL("http://bar/search?q={searchTerms}"); | |
1176 data.instant_url = "http://bar/instant#q={searchTerms}"; | |
1177 data.alternate_urls.push_back("http://bar/?q={searchTerms}"); | |
1178 data.alternate_urls.push_back("http://bar/#q={searchTerms}"); | |
1179 data.alternate_urls.push_back("http://bar/search#q{searchTerms}"); | |
1180 data.alternate_urls.push_back("http://bar/webhp#q={searchTerms}"); | |
1181 TemplateURL search_provider(NULL, data); | |
1182 | |
1183 static const struct { | |
Peter Kasting
2013/08/06 21:32:19
Nit: Hmm, should this really be static and not jus
rpetterson
2013/08/06 23:04:17
True. Static is probably unnecessary. I was lookin
| |
1184 const char* const url; | |
1185 bool result; | |
1186 } url_data[] = { | |
1187 { "http://bar/search?q=foo&oq=foo", true, }, | |
1188 { "http://bar/?q=foo&oq=foo", true, }, | |
1189 { "http://bar/#output=search&q=foo&oq=foo", true, }, | |
1190 { "http://bar/webhp#q=foo&oq=foo", true, }, | |
1191 { "http://bar/#q=foo&oq=foo", true, }, | |
1192 { "http://bar/?ext=foo&q=foo#ref=bar", true, }, | |
1193 { "http://bar/url?url=http://www.foo.com/&q=foo#ref=bar", false, }, | |
1194 { "http://bar/", false, }, | |
1195 { "http://foo/", false, }, | |
1196 }; | |
1197 | |
1198 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(url_data); ++i) { | |
1199 bool is_search_results_page = | |
1200 search_provider.IsSearchURL(GURL(url_data[i].url)); | |
Peter Kasting
2013/08/06 21:32:19
Nit: I'd just inline this below and save a line, i
rpetterson
2013/08/06 23:04:17
Done.
| |
1201 EXPECT_EQ(is_search_results_page, url_data[i].result); | |
Peter Kasting
2013/08/06 21:32:19
Nit: (expected, actual)
rpetterson
2013/08/06 23:04:17
Done.
| |
1202 } | |
1203 } | |
OLD | NEW |