Chromium Code Reviews| Index: chrome/browser/search/search_unittest.cc |
| diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc |
| index 94aae245412189d23b1242ba5ce734250c3ba3df..2831c7f66e02acd511603c5d0a7b5fd2b430f0fd 100644 |
| --- a/chrome/browser/search/search_unittest.cc |
| +++ b/chrome/browser/search/search_unittest.cc |
| @@ -799,6 +799,56 @@ TEST_F(SearchTest, GetSearchResultPrefetchBaseURL) { |
| GetSearchResultPrefetchBaseURL(profile())); |
| } |
| +struct SearchURLTestCase { |
|
samarth
2014/02/12 18:02:39
s/SearchURLTestCase/ExtractSearchTermsTestCase/
kmadhusu
2014/02/12 19:58:09
Done.
|
| + const char* url; |
| + const char* expected_result; |
| + const char* comment; |
| +}; |
| + |
| +TEST_F(SearchTest, ExtractSearchTermsFromURL) { |
| + const SearchURLTestCase kTestCases[] = { |
| + {chrome::kChromeSearchLocalNtpUrl, "", "NTP url"}, |
| + {"https://foo.com/instant?strk", "", "Invalid search url"}, |
| + {"https://foo.com/instant#strk", "", "Invalid search url"}, |
| + {"https://foo.com/alt#quux=foo", "foo", "Valid search url"}, |
| + {"https://foo.com/alt#quux=foo&strk", "foo", "Valid search url"} |
| + }; |
| + |
| + for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
| + const SearchURLTestCase& test = kTestCases[i]; |
| + EXPECT_EQ( |
| + test.expected_result, |
| + UTF16ToASCII(chrome::ExtractSearchTermsFromURL(profile(), |
| + GURL(test.url)))) |
| + << test.url << " " << test.comment; |
| + } |
| +} |
| + |
| +struct InstantURLTestCase { |
|
samarth
2014/02/12 18:02:39
QueryExtractionAllowedTestCase
kmadhusu
2014/02/12 19:58:09
Done.
|
| + const char* url; |
| + bool expected_result; |
| + const char* comment; |
| +}; |
| + |
| +TEST_F(SearchTest, IsQueryExtractionAllowedForURL) { |
| + const InstantURLTestCase kTestCases[] = { |
| + {"http://foo.com/instant?strk", false, "HTTP URL"}, |
| + {"https://foo.com/instant?strk", true, "Valid URL"}, |
| + {"https://foo.com/instant?", false, |
| + "No search terms replacement key"}, |
| + {"https://foo.com/alt#quux=foo", false, |
| + "No search terms replacement key"}, |
| + {"https://foo.com/alt#quux=foo&strk", true, "Valid search url"} |
| + }; |
| + |
| + for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
| + const InstantURLTestCase& test = kTestCases[i]; |
| + EXPECT_EQ(test.expected_result, |
| + chrome::IsQueryExtractionAllowedForURL(profile(), GURL(test.url))) |
| + << test.url << " " << test.comment; |
| + } |
| +} |
| + |
| typedef SearchTest IsQueryExtractionEnabledTest; |
| TEST_F(IsQueryExtractionEnabledTest, NotSet) { |