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.
|
+ } |
+} |