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

Unified 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: remove unnecessary include 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/template_url_unittest.cc
diff --git a/chrome/browser/search_engines/template_url_unittest.cc b/chrome/browser/search_engines/template_url_unittest.cc
index a4d38a53261bbf9b5073aa453be878711ec935c6..318f62cfec9a12b287491e87c694f0f1eebd6cc7 100644
--- a/chrome/browser/search_engines/template_url_unittest.cc
+++ b/chrome/browser/search_engines/template_url_unittest.cc
@@ -1168,3 +1168,36 @@ TEST_F(TemplateURLTest, ExtraQueryParams) {
EXPECT_EQ("http://www.google.com/search?q=abc#oq=def&x",
url.url_ref().ReplaceSearchTerms(search_terms));
}
+
+// Test the IsSearchResults function.
+TEST_F(TemplateURLTest, IsSearchResults) {
+ TemplateURLData data;
+ data.SetURL("http://bar/search?q={searchTerms}");
+ data.instant_url = "http://bar/instant#q={searchTerms}";
+ data.alternate_urls.push_back("http://bar/?q={searchTerms}");
+ data.alternate_urls.push_back("http://bar/#q={searchTerms}");
+ data.alternate_urls.push_back("http://bar/search#q{searchTerms}");
+ data.alternate_urls.push_back("http://bar/webhp#q={searchTerms}");
+ TemplateURL search_provider(NULL, data);
+
+ 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
+ const char* const url;
+ bool result;
+ } url_data[] = {
+ { "http://bar/search?q=foo&oq=foo", true, },
+ { "http://bar/?q=foo&oq=foo", true, },
+ { "http://bar/#output=search&q=foo&oq=foo", true, },
+ { "http://bar/webhp#q=foo&oq=foo", true, },
+ { "http://bar/#q=foo&oq=foo", true, },
+ { "http://bar/?ext=foo&q=foo#ref=bar", true, },
+ { "http://bar/url?url=http://www.foo.com/&q=foo#ref=bar", false, },
+ { "http://bar/", false, },
+ { "http://foo/", false, },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(url_data); ++i) {
+ bool is_search_results_page =
+ 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.
+ 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.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698