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

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

Issue 21395002: [InstantExtended] Fixing how PageLoadSRP is emitted. Previously it was emitted only for Instant sea… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: responding to comments Created 7 years, 4 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/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
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 const struct {
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 EXPECT_EQ(url_data[i].result,
1200 search_provider.IsSearchURL(GURL(url_data[i].url)));
1201 }
1202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698