[email protected] | 58b6433 | 2010-08-13 16:09:39 | [diff] [blame^] | 1 | // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 12bd0587 | 2009-03-17 19:25:06 | [diff] [blame] | 5 | #include "base/base_paths.h" |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 6 | #include "base/string_util.h" |
[email protected] | 64048bd | 2010-03-08 23:28:58 | [diff] [blame] | 7 | #include "base/utf_string_conversions.h" |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 8 | #include "chrome/browser/browser_process.h" |
| 9 | #include "chrome/browser/rlz/rlz.h" |
[email protected] | d54e03a5 | 2009-01-16 00:31:04 | [diff] [blame] | 10 | #include "chrome/browser/search_engines/template_url.h" |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 11 | #include "testing/gtest/include/gtest/gtest.h" |
| 12 | |
| 13 | class TemplateURLTest : public testing::Test { |
| 14 | public: |
| 15 | virtual void TearDown() { |
| 16 | delete TemplateURLRef::google_base_url_; |
| 17 | TemplateURLRef::google_base_url_ = NULL; |
| 18 | } |
| 19 | |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 20 | void CheckSuggestBaseURL(const char* base_url, |
| 21 | const char* base_suggest_url) const { |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 22 | delete TemplateURLRef::google_base_url_; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 23 | TemplateURLRef::google_base_url_ = new std::string(base_url); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 24 | EXPECT_STREQ(base_suggest_url, |
| 25 | TemplateURLRef::GoogleBaseSuggestURLValue().c_str()); |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | TEST_F(TemplateURLTest, Defaults) { |
| 30 | TemplateURL url; |
| 31 | ASSERT_FALSE(url.show_in_default_list()); |
| 32 | ASSERT_FALSE(url.safe_for_autoreplace()); |
| 33 | ASSERT_EQ(0, url.prepopulate_id()); |
| 34 | } |
| 35 | |
| 36 | TEST_F(TemplateURLTest, TestValidWithComplete) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 37 | TemplateURLRef ref("{searchTerms}", 0, 0); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 38 | ASSERT_TRUE(ref.IsValid()); |
| 39 | } |
| 40 | |
| 41 | TEST_F(TemplateURLTest, URLRefTestSearchTerms) { |
[email protected] | 0d2e6a6 | 2010-01-15 20:09:19 | [diff] [blame] | 42 | struct SearchTermsCase { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 43 | const char* url; |
[email protected] | 0d2e6a6 | 2010-01-15 20:09:19 | [diff] [blame] | 44 | const wchar_t* terms; |
| 45 | const char* output; |
| 46 | } search_term_cases[] = { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 47 | { "http://foo{searchTerms}", L"sea rch/bar", "http://foosea%20rch/bar" }, |
| 48 | { "http://foo{searchTerms}?boo=abc", L"sea rch/bar", |
[email protected] | 3c75f0d | 2010-03-02 05:51:17 | [diff] [blame] | 49 | "http://foosea%20rch/bar?boo=abc" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 50 | { "http://foo/?boo={searchTerms}", L"sea rch/bar", |
[email protected] | 3c75f0d | 2010-03-02 05:51:17 | [diff] [blame] | 51 | "http://foo/?boo=sea+rch%2Fbar" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 52 | { "http://en.wikipedia.org/{searchTerms}", L"wiki/?", |
[email protected] | 3c75f0d | 2010-03-02 05:51:17 | [diff] [blame] | 53 | "http://en.wikipedia.org/wiki/%3F" } |
[email protected] | 0d2e6a6 | 2010-01-15 20:09:19 | [diff] [blame] | 54 | }; |
| 55 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(search_term_cases); ++i) { |
| 56 | const SearchTermsCase& value = search_term_cases[i]; |
| 57 | TemplateURL t_url; |
| 58 | TemplateURLRef ref(value.url, 0, 0); |
| 59 | ASSERT_TRUE(ref.IsValid()); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 60 | |
[email protected] | 0d2e6a6 | 2010-01-15 20:09:19 | [diff] [blame] | 61 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 62 | GURL result = GURL(ref.ReplaceSearchTerms(t_url, value.terms, |
| 63 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | 0d2e6a6 | 2010-01-15 20:09:19 | [diff] [blame] | 64 | ASSERT_TRUE(result.is_valid()); |
| 65 | ASSERT_EQ(value.output, result.spec()); |
| 66 | } |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | TEST_F(TemplateURLTest, URLRefTestCount) { |
| 70 | TemplateURL t_url; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 71 | TemplateURLRef ref("http://foo{searchTerms}{count?}", 0, 0); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 72 | ASSERT_TRUE(ref.IsValid()); |
| 73 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 74 | GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X", |
| 75 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 76 | ASSERT_TRUE(result.is_valid()); |
| 77 | ASSERT_EQ("http://foox/", result.spec()); |
| 78 | } |
| 79 | |
| 80 | TEST_F(TemplateURLTest, URLRefTestCount2) { |
| 81 | TemplateURL t_url; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 82 | TemplateURLRef ref("http://foo{searchTerms}{count}", 0, 0); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 83 | ASSERT_TRUE(ref.IsValid()); |
| 84 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 85 | GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X", |
| 86 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 87 | ASSERT_TRUE(result.is_valid()); |
| 88 | ASSERT_EQ("http://foox10/", result.spec()); |
| 89 | } |
| 90 | |
| 91 | TEST_F(TemplateURLTest, URLRefTestIndices) { |
| 92 | TemplateURL t_url; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 93 | TemplateURLRef ref("http://foo{searchTerms}x{startIndex?}y{startPage?}", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 94 | 1, 2); |
| 95 | ASSERT_TRUE(ref.IsValid()); |
| 96 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 97 | GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X", |
| 98 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 99 | ASSERT_TRUE(result.is_valid()); |
| 100 | ASSERT_EQ("http://fooxxy/", result.spec()); |
| 101 | } |
| 102 | |
| 103 | TEST_F(TemplateURLTest, URLRefTestIndices2) { |
| 104 | TemplateURL t_url; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 105 | TemplateURLRef ref("http://foo{searchTerms}x{startIndex}y{startPage}", 1, 2); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 106 | ASSERT_TRUE(ref.IsValid()); |
| 107 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 108 | GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X", |
| 109 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 110 | ASSERT_TRUE(result.is_valid()); |
| 111 | ASSERT_EQ("http://fooxx1y2/", result.spec()); |
| 112 | } |
| 113 | |
| 114 | TEST_F(TemplateURLTest, URLRefTestEncoding) { |
| 115 | TemplateURL t_url; |
| 116 | TemplateURLRef ref( |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 117 | "http://foo{searchTerms}x{inputEncoding?}y{outputEncoding?}a", 1, 2); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 118 | ASSERT_TRUE(ref.IsValid()); |
| 119 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 120 | GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X", |
| 121 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 122 | ASSERT_TRUE(result.is_valid()); |
| 123 | ASSERT_EQ("http://fooxxutf-8ya/", result.spec()); |
| 124 | } |
| 125 | |
| 126 | TEST_F(TemplateURLTest, InputEncodingBeforeSearchTerm) { |
| 127 | TemplateURL t_url; |
| 128 | TemplateURLRef ref( |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 129 | "http://foox{inputEncoding?}a{searchTerms}y{outputEncoding?}b", 1, 2); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 130 | ASSERT_TRUE(ref.IsValid()); |
| 131 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 132 | GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X", |
| 133 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 134 | ASSERT_TRUE(result.is_valid()); |
| 135 | ASSERT_EQ("http://fooxutf-8axyb/", result.spec()); |
| 136 | } |
| 137 | |
| 138 | TEST_F(TemplateURLTest, URLRefTestEncoding2) { |
| 139 | TemplateURL t_url; |
| 140 | TemplateURLRef ref( |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 141 | "http://foo{searchTerms}x{inputEncoding}y{outputEncoding}a", 1, 2); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 142 | ASSERT_TRUE(ref.IsValid()); |
| 143 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 144 | GURL result = GURL(ref.ReplaceSearchTerms(t_url, L"X", |
| 145 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 146 | ASSERT_TRUE(result.is_valid()); |
| 147 | ASSERT_EQ("http://fooxxutf-8yutf-8a/", result.spec()); |
| 148 | } |
| 149 | |
| 150 | TEST_F(TemplateURLTest, URLRefTermToWide) { |
| 151 | struct ToWideCase { |
| 152 | const char* encoded_search_term; |
| 153 | const wchar_t* expected_decoded_term; |
| 154 | } to_wide_cases[] = { |
| 155 | {"hello+world", L"hello world"}, |
| 156 | // Test some big-5 input. |
| 157 | {"%a7A%A6%6e+to+you", L"\x4f60\x597d to you"}, |
| 158 | // Test some UTF-8 input. We should fall back to this when the encoding |
| 159 | // doesn't look like big-5. We have a '5' in the middle, which is an invalid |
| 160 | // Big-5 trailing byte. |
| 161 | {"%e4%bd%a05%e5%a5%bd+to+you", L"\x4f60\x35\x597d to you"}, |
| 162 | // Undecodable input should stay escaped. |
| 163 | {"%91%01+abcd", L"%91%01 abcd"}, |
[email protected] | 7df4348 | 2009-07-31 19:37:44 | [diff] [blame] | 164 | // Make sure we convert %2B to +. |
| 165 | {"C%2B%2B", L"C++"}, |
| 166 | // C%2B is escaped as C%252B, make sure we unescape it properly. |
| 167 | {"C%252B", L"C%2B"}, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | TemplateURL t_url; |
| 171 | |
| 172 | // Set one input encoding: big-5. This is so we can test fallback to UTF-8. |
| 173 | std::vector<std::string> encodings; |
| 174 | encodings.push_back("big-5"); |
| 175 | t_url.set_input_encodings(encodings); |
| 176 | |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 177 | TemplateURLRef ref("http://foo?q={searchTerms}", 1, 2); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 178 | ASSERT_TRUE(ref.IsValid()); |
| 179 | ASSERT_TRUE(ref.SupportsReplacement()); |
| 180 | |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 181 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(to_wide_cases); i++) { |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 182 | std::wstring result = ref.SearchTermToWide(t_url, |
| 183 | to_wide_cases[i].encoded_search_term); |
| 184 | |
| 185 | EXPECT_EQ(std::wstring(to_wide_cases[i].expected_decoded_term), result); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | TEST_F(TemplateURLTest, SetFavIcon) { |
| 190 | TemplateURL url; |
| 191 | GURL favicon_url("http://favicon.url"); |
| 192 | url.SetFavIconURL(favicon_url); |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 193 | ASSERT_EQ(1U, url.image_refs().size()); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 194 | ASSERT_TRUE(favicon_url == url.GetFavIconURL()); |
| 195 | |
| 196 | GURL favicon_url2("http://favicon2.url"); |
| 197 | url.SetFavIconURL(favicon_url2); |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 198 | ASSERT_EQ(1U, url.image_refs().size()); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 199 | ASSERT_TRUE(favicon_url2 == url.GetFavIconURL()); |
| 200 | } |
| 201 | |
| 202 | TEST_F(TemplateURLTest, DisplayURLToURLRef) { |
| 203 | struct TestData { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 204 | const std::string url; |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 205 | const std::wstring expected_result; |
| 206 | } data[] = { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 207 | { "http://foo{searchTerms}x{inputEncoding}y{outputEncoding}a", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 208 | L"http://foo%sx{inputEncoding}y{outputEncoding}a" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 209 | { "http://X", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 210 | L"http://X" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 211 | { "http://foo{searchTerms", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 212 | L"http://foo{searchTerms" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 213 | { "http://foo{searchTerms}{language}", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 214 | L"http://foo%s{language}" }, |
| 215 | }; |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 216 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 217 | TemplateURLRef ref(data[i].url, 1, 2); |
| 218 | EXPECT_EQ(data[i].expected_result, ref.DisplayURL()); |
| 219 | EXPECT_EQ(data[i].url, |
| 220 | TemplateURLRef::DisplayURLToURLRef(ref.DisplayURL())); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | TEST_F(TemplateURLTest, ReplaceSearchTerms) { |
| 225 | struct TestData { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 226 | const std::string url; |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 227 | const std::string expected_result; |
| 228 | } data[] = { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 229 | { "http://foo/{language}{searchTerms}{inputEncoding}", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 230 | "http://foo/{language}XUTF-8" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 231 | { "http://foo/{language}{inputEncoding}{searchTerms}", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 232 | "http://foo/{language}UTF-8X" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 233 | { "http://foo/{searchTerms}{language}{inputEncoding}", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 234 | "http://foo/X{language}UTF-8" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 235 | { "http://foo/{searchTerms}{inputEncoding}{language}", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 236 | "http://foo/XUTF-8{language}" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 237 | { "http://foo/{inputEncoding}{searchTerms}{language}", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 238 | "http://foo/UTF-8X{language}" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 239 | { "http://foo/{inputEncoding}{language}{searchTerms}", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 240 | "http://foo/UTF-8{language}X" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 241 | { "http://foo/{language}a{searchTerms}a{inputEncoding}a", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 242 | "http://foo/{language}aXaUTF-8a" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 243 | { "http://foo/{language}a{inputEncoding}a{searchTerms}a", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 244 | "http://foo/{language}aUTF-8aXa" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 245 | { "http://foo/{searchTerms}a{language}a{inputEncoding}a", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 246 | "http://foo/Xa{language}aUTF-8a" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 247 | { "http://foo/{searchTerms}a{inputEncoding}a{language}a", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 248 | "http://foo/XaUTF-8a{language}a" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 249 | { "http://foo/{inputEncoding}a{searchTerms}a{language}a", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 250 | "http://foo/UTF-8aXa{language}a" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 251 | { "http://foo/{inputEncoding}a{language}a{searchTerms}a", |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 252 | "http://foo/UTF-8a{language}aXa" }, |
| 253 | }; |
| 254 | TemplateURL turl; |
| 255 | turl.add_input_encoding("UTF-8"); |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 256 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 257 | TemplateURLRef ref(data[i].url, 1, 2); |
| 258 | EXPECT_TRUE(ref.IsValid()); |
| 259 | EXPECT_TRUE(ref.SupportsReplacement()); |
| 260 | std::string expected_result = data[i].expected_result; |
| 261 | ReplaceSubstringsAfterOffset(&expected_result, 0, "{language}", |
[email protected] | d70539de | 2009-06-24 22:17:06 | [diff] [blame] | 262 | g_browser_process->GetApplicationLocale()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 263 | GURL result = GURL(ref.ReplaceSearchTerms(turl, L"X", |
| 264 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 265 | EXPECT_TRUE(result.is_valid()); |
| 266 | EXPECT_EQ(expected_result, result.spec()); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | |
| 271 | // Tests replacing search terms in various encodings and making sure the |
| 272 | // generated URL matches the expected value. |
| 273 | TEST_F(TemplateURLTest, ReplaceArbitrarySearchTerms) { |
| 274 | struct TestData { |
| 275 | const std::string encoding; |
| 276 | const std::wstring search_term; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 277 | const std::string url; |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 278 | const std::string expected_result; |
| 279 | } data[] = { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 280 | { "BIG5", L"\x60BD", "http://foo/?{searchTerms}{inputEncoding}", |
[email protected] | 3c75f0d | 2010-03-02 05:51:17 | [diff] [blame] | 281 | "http://foo/?%B1~BIG5" }, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 282 | { "UTF-8", L"blah", "http://foo/?{searchTerms}{inputEncoding}", |
[email protected] | 3c75f0d | 2010-03-02 05:51:17 | [diff] [blame] | 283 | "http://foo/?blahUTF-8" }, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 284 | }; |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 285 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 286 | TemplateURL turl; |
| 287 | turl.add_input_encoding(data[i].encoding); |
| 288 | TemplateURLRef ref(data[i].url, 1, 2); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 289 | GURL result = GURL(ref.ReplaceSearchTerms(turl, |
[email protected] | 7b9f367 | 2009-06-15 18:31:22 | [diff] [blame] | 290 | data[i].search_term, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 291 | std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 292 | EXPECT_TRUE(result.is_valid()); |
| 293 | EXPECT_EQ(data[i].expected_result, result.spec()); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | TEST_F(TemplateURLTest, Suggestions) { |
| 298 | struct TestData { |
| 299 | const int accepted_suggestion; |
| 300 | const std::wstring original_query_for_suggestion; |
| 301 | const std::string expected_result; |
| 302 | } data[] = { |
| 303 | { TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring(), |
| 304 | "http://bar/foo?q=foobar" }, |
| 305 | { TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, L"foo", |
| 306 | "http://bar/foo?q=foobar" }, |
| 307 | { TemplateURLRef::NO_SUGGESTION_CHOSEN, std::wstring(), |
| 308 | "http://bar/foo?aq=f&q=foobar" }, |
| 309 | { TemplateURLRef::NO_SUGGESTION_CHOSEN, L"foo", |
| 310 | "http://bar/foo?aq=f&q=foobar" }, |
| 311 | { 0, std::wstring(), "http://bar/foo?aq=0&oq=&q=foobar" }, |
| 312 | { 1, L"foo", "http://bar/foo?aq=1&oq=foo&q=foobar" }, |
| 313 | }; |
| 314 | TemplateURL turl; |
| 315 | turl.add_input_encoding("UTF-8"); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 316 | TemplateURLRef ref("http://bar/foo?{google:acceptedSuggestion}" |
| 317 | "{google:originalQueryForSuggestion}q={searchTerms}", 1, 2); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 318 | ASSERT_TRUE(ref.IsValid()); |
| 319 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 320 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 321 | GURL result = GURL(ref.ReplaceSearchTerms(turl, L"foobar", |
| 322 | data[i].accepted_suggestion, data[i].original_query_for_suggestion)); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 323 | EXPECT_TRUE(result.is_valid()); |
| 324 | EXPECT_EQ(data[i].expected_result, result.spec()); |
| 325 | } |
| 326 | } |
| 327 | |
[email protected] | 12bd0587 | 2009-03-17 19:25:06 | [diff] [blame] | 328 | #if defined(OS_WIN) |
[email protected] | 81f808de | 2009-09-25 01:36:34 | [diff] [blame] | 329 | TEST_F(TemplateURLTest, RLZ) { |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 330 | std::wstring rlz_string; |
[email protected] | 58b6433 | 2010-08-13 16:09:39 | [diff] [blame^] | 331 | #if defined(GOOGLE_CHROME_BUILD) |
[email protected] | 1c26217 | 2010-06-10 15:25:46 | [diff] [blame] | 332 | RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); |
[email protected] | 58b6433 | 2010-08-13 16:09:39 | [diff] [blame^] | 333 | #endif |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 334 | |
| 335 | TemplateURL t_url; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 336 | TemplateURLRef ref("http://bar/?{google:RLZ}{searchTerms}", 1, 2); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 337 | ASSERT_TRUE(ref.IsValid()); |
| 338 | ASSERT_TRUE(ref.SupportsReplacement()); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 339 | GURL result(ref.ReplaceSearchTerms(t_url, L"x", |
| 340 | TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 341 | ASSERT_TRUE(result.is_valid()); |
[email protected] | 12bd0587 | 2009-03-17 19:25:06 | [diff] [blame] | 342 | std::string expected_url = "http://bar/?"; |
| 343 | if (!rlz_string.empty()) { |
| 344 | expected_url += "rlz=" + WideToUTF8(rlz_string) + "&"; |
| 345 | } |
| 346 | expected_url += "x"; |
| 347 | ASSERT_EQ(expected_url, result.spec()); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 348 | } |
[email protected] | 81f808de | 2009-09-25 01:36:34 | [diff] [blame] | 349 | #endif |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 350 | |
| 351 | TEST_F(TemplateURLTest, HostAndSearchTermKey) { |
| 352 | struct TestData { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 353 | const std::string url; |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 354 | const std::string host; |
| 355 | const std::string path; |
| 356 | const std::string search_term_key; |
| 357 | } data[] = { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 358 | { "http://blah/?foo=bar&q={searchTerms}&b=x", "blah", "/", "q"}, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 359 | |
| 360 | // No query key should result in empty values. |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 361 | { "http://blah/{searchTerms}", "", "", ""}, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 362 | |
| 363 | // No term should result in empty values. |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 364 | { "http://blah/", "", "", ""}, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 365 | |
| 366 | // Multiple terms should result in empty values. |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 367 | { "http://blah/?q={searchTerms}&x={searchTerms}", "", "", ""}, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 368 | |
| 369 | // Term in the host shouldn't match. |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 370 | { "http://{searchTerms}", "", "", ""}, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 371 | |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 372 | { "http://blah/?q={searchTerms}", "blah", "/", "q"}, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 373 | |
| 374 | // Single term with extra chars in value should match. |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 375 | { "http://blah/?q=stock:{searchTerms}", "blah", "/", "q"}, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 376 | }; |
| 377 | |
| 378 | TemplateURL t_url; |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 379 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 380 | t_url.SetURL(data[i].url, 0, 0); |
| 381 | EXPECT_EQ(data[i].host, t_url.url()->GetHost()); |
| 382 | EXPECT_EQ(data[i].path, t_url.url()->GetPath()); |
| 383 | EXPECT_EQ(data[i].search_term_key, t_url.url()->GetSearchTermKey()); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | TEST_F(TemplateURLTest, GoogleBaseSuggestURL) { |
| 388 | static const struct { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 389 | const char* const base_url; |
| 390 | const char* const base_suggest_url; |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 391 | } data[] = { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 392 | { "http://google.com/", "http://clients1.google.com/complete/", }, |
| 393 | { "http://www.google.com/", "http://clients1.google.com/complete/", }, |
| 394 | { "http://www.google.co.uk/", "http://clients1.google.co.uk/complete/", }, |
| 395 | { "http://www.google.com.by/", |
| 396 | "http://clients1.google.com.by/complete/", }, |
| 397 | { "http://google.com/intl/xx/", "http://clients1.google.com/complete/", }, |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 398 | }; |
| 399 | |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 400 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 401 | CheckSuggestBaseURL(data[i].base_url, data[i].base_suggest_url); |
| 402 | } |
| 403 | |
| 404 | TEST_F(TemplateURLTest, Keyword) { |
| 405 | TemplateURL t_url; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 406 | t_url.SetURL("http://www.google.com/search", 0, 0); |
[email protected] | d82443b | 2009-01-15 19:54:56 | [diff] [blame] | 407 | EXPECT_FALSE(t_url.autogenerate_keyword()); |
| 408 | t_url.set_keyword(L"foo"); |
| 409 | EXPECT_EQ(L"foo", t_url.keyword()); |
| 410 | t_url.set_autogenerate_keyword(true); |
| 411 | EXPECT_TRUE(t_url.autogenerate_keyword()); |
| 412 | EXPECT_EQ(L"google.com", t_url.keyword()); |
| 413 | t_url.set_keyword(L"foo"); |
| 414 | EXPECT_FALSE(t_url.autogenerate_keyword()); |
| 415 | EXPECT_EQ(L"foo", t_url.keyword()); |
| 416 | } |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 417 | |
| 418 | TEST_F(TemplateURLTest, ParseParameterKnown) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 419 | std::string parsed_url("{searchTerms}"); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 420 | TemplateURLRef url_ref(parsed_url, 0, 0); |
| 421 | TemplateURLRef::Replacements replacements; |
| 422 | EXPECT_TRUE(url_ref.ParseParameter(0, 12, &parsed_url, &replacements)); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 423 | EXPECT_EQ(std::string(), parsed_url); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 424 | ASSERT_EQ(1U, replacements.size()); |
[email protected] | 4c66d2a | 2010-05-11 04:36:05 | [diff] [blame] | 425 | EXPECT_EQ(static_cast<size_t>(0), replacements[0].index); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 426 | EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); |
| 427 | } |
| 428 | |
| 429 | TEST_F(TemplateURLTest, ParseParameterUnknown) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 430 | std::string parsed_url("{}"); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 431 | TemplateURLRef url_ref(parsed_url, 0, 0); |
| 432 | TemplateURLRef::Replacements replacements; |
| 433 | EXPECT_FALSE(url_ref.ParseParameter(0, 1, &parsed_url, &replacements)); |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 434 | EXPECT_EQ("{}", parsed_url); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 435 | EXPECT_TRUE(replacements.empty()); |
| 436 | } |
| 437 | |
| 438 | TEST_F(TemplateURLTest, ParseURLEmpty) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 439 | TemplateURLRef url_ref("", 0, 0); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 440 | TemplateURLRef::Replacements replacements; |
| 441 | bool valid = false; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 442 | EXPECT_EQ(std::string(), url_ref.ParseURL("", &replacements, &valid)); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 443 | EXPECT_TRUE(replacements.empty()); |
| 444 | EXPECT_TRUE(valid); |
| 445 | } |
| 446 | |
| 447 | TEST_F(TemplateURLTest, ParseURLNoTemplateEnd) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 448 | TemplateURLRef url_ref("{", 0, 0); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 449 | TemplateURLRef::Replacements replacements; |
| 450 | bool valid = false; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 451 | EXPECT_EQ(std::string(), url_ref.ParseURL("{", &replacements, &valid)); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 452 | EXPECT_TRUE(replacements.empty()); |
| 453 | EXPECT_FALSE(valid); |
| 454 | } |
| 455 | |
| 456 | TEST_F(TemplateURLTest, ParseURLNoKnownParameters) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 457 | TemplateURLRef url_ref("{}", 0, 0); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 458 | TemplateURLRef::Replacements replacements; |
| 459 | bool valid = false; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 460 | EXPECT_EQ("{}", url_ref.ParseURL("{}", &replacements, &valid)); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 461 | EXPECT_TRUE(replacements.empty()); |
| 462 | EXPECT_TRUE(valid); |
| 463 | } |
| 464 | |
| 465 | TEST_F(TemplateURLTest, ParseURLTwoParameters) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 466 | TemplateURLRef url_ref("{}{{%s}}", 0, 0); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 467 | TemplateURLRef::Replacements replacements; |
| 468 | bool valid = false; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 469 | EXPECT_EQ("{}{}", |
| 470 | url_ref.ParseURL("{}{{searchTerms}}", &replacements, &valid)); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 471 | ASSERT_EQ(1U, replacements.size()); |
[email protected] | 4c66d2a | 2010-05-11 04:36:05 | [diff] [blame] | 472 | EXPECT_EQ(static_cast<size_t>(3), replacements[0].index); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 473 | EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); |
| 474 | EXPECT_TRUE(valid); |
| 475 | } |
| 476 | |
| 477 | TEST_F(TemplateURLTest, ParseURLNestedParameter) { |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 478 | TemplateURLRef url_ref("{%s", 0, 0); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 479 | TemplateURLRef::Replacements replacements; |
| 480 | bool valid = false; |
[email protected] | ddd231e | 2010-06-29 20:35:19 | [diff] [blame] | 481 | EXPECT_EQ("{", url_ref.ParseURL("{{searchTerms}", &replacements, &valid)); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 482 | ASSERT_EQ(1U, replacements.size()); |
[email protected] | 4c66d2a | 2010-05-11 04:36:05 | [diff] [blame] | 483 | EXPECT_EQ(static_cast<size_t>(1), replacements[0].index); |
[email protected] | 81c6ef6 | 2010-01-21 09:58:47 | [diff] [blame] | 484 | EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); |
| 485 | EXPECT_TRUE(valid); |
| 486 | } |