OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 data.contextual_search_url = "{google:baseURL}_/contextualsearch"; | 1888 data.contextual_search_url = "{google:baseURL}_/contextualsearch"; |
1889 data.image_url_post_params = "encoded_image={google:imageThumbnail}"; | 1889 data.image_url_post_params = "encoded_image={google:imageThumbnail}"; |
1890 data.alternate_urls.push_back("{google:baseURL}s#q={searchTerms}"); | 1890 data.alternate_urls.push_back("{google:baseURL}s#q={searchTerms}"); |
1891 // search_terms_replacement_key with value of | 1891 // search_terms_replacement_key with value of |
1892 // "{google:instantExtendedEnabledKey}" is replaced inside TemplateUrl | 1892 // "{google:instantExtendedEnabledKey}" is replaced inside TemplateUrl |
1893 // constructor so must be handled specially inside MatchesData. | 1893 // constructor so must be handled specially inside MatchesData. |
1894 data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}"; | 1894 data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}"; |
1895 TemplateURL url(data); | 1895 TemplateURL url(data); |
1896 EXPECT_TRUE(TemplateURL::MatchesData(&url, &data, search_terms_data_)); | 1896 EXPECT_TRUE(TemplateURL::MatchesData(&url, &data, search_terms_data_)); |
1897 } | 1897 } |
| 1898 |
| 1899 // Test for correct replacement of GoogleInstantExtendedEnabledKey param. |
| 1900 TEST_F(TemplateURLTest, GoogleInstantExtendedEnabledReplacement) { |
| 1901 TemplateURLData data; |
| 1902 data.SetURL( |
| 1903 "{google:baseURL}search/" |
| 1904 "?{google:instantExtendedEnabledKey}&q={searchTerms}"); |
| 1905 data.SetShortName(ASCIIToUTF16("Google")); |
| 1906 data.SetKeyword(ASCIIToUTF16("google.com")); |
| 1907 data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}"; |
| 1908 TemplateURL turl(data); |
| 1909 EXPECT_TRUE(TemplateURL::MatchesData(&turl, &data, search_terms_data_)); |
| 1910 // Expect that replacement of search_terms_replacement_key in TemplateURL |
| 1911 // constructor is correct. |
| 1912 EXPECT_EQ("espv", turl.search_terms_replacement_key()); |
| 1913 // Expect that replacement of {google:instantExtendedEnabledKey} in search url |
| 1914 // is correct. |
| 1915 GURL search_generated = turl.GenerateSearchURL(search_terms_data_); |
| 1916 EXPECT_EQ("http://www.google.com/search/?espv&q=blah.blah.blah.blah.blah", |
| 1917 search_generated.spec()); |
| 1918 EXPECT_TRUE(turl.HasSearchTermsReplacementKey(search_generated)); |
| 1919 } |
OLD | NEW |