OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/rlz/rlz.h" | 9 #include "chrome/browser/rlz/rlz.h" |
10 #include "chrome/browser/search_engines/search_terms_data.h" | 10 #include "chrome/browser/search_engines/search_terms_data.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 TemplateURLRef ref( | 145 TemplateURLRef ref( |
146 "http://foo{searchTerms}x{inputEncoding?}y{outputEncoding?}a", 1, 2); | 146 "http://foo{searchTerms}x{inputEncoding?}y{outputEncoding?}a", 1, 2); |
147 ASSERT_TRUE(ref.IsValid()); | 147 ASSERT_TRUE(ref.IsValid()); |
148 ASSERT_TRUE(ref.SupportsReplacement()); | 148 ASSERT_TRUE(ref.SupportsReplacement()); |
149 GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"), | 149 GURL result = GURL(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("X"), |
150 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); | 150 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); |
151 ASSERT_TRUE(result.is_valid()); | 151 ASSERT_TRUE(result.is_valid()); |
152 ASSERT_EQ("http://fooxxutf-8ya/", result.spec()); | 152 ASSERT_EQ("http://fooxxutf-8ya/", result.spec()); |
153 } | 153 } |
154 | 154 |
| 155 // Test that setting the prepopulate ID from TemplateURL causes the stored |
| 156 // TemplateURLRef to handle parsing the URL parameters differently. |
155 TEST_F(TemplateURLTest, SetPrepopulatedAndParse) { | 157 TEST_F(TemplateURLTest, SetPrepopulatedAndParse) { |
156 TemplateURL t_url; | 158 TemplateURL t_url; |
157 t_url.SetURL("http://foo{fhqwhgads}", 0, 0); | 159 t_url.SetURL("http://foo{fhqwhgads}", 0, 0); |
158 TemplateURLRef::Replacements replacements; | 160 TemplateURLRef::Replacements replacements; |
159 bool valid = false; | 161 bool valid = false; |
160 | 162 |
161 t_url.SetPrepopulateId(0); | 163 t_url.SetPrepopulateId(0); |
162 EXPECT_EQ("http://foo{fhqwhgads}", | 164 EXPECT_EQ("http://foo{fhqwhgads}", |
163 t_url.url()->ParseURL("http://foo{fhqwhgads}", | 165 t_url.url()->ParseURL("http://foo{fhqwhgads}", |
164 &replacements, | 166 &replacements, |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 TEST_F(TemplateURLTest, ParseURLNestedParameter) { | 572 TEST_F(TemplateURLTest, ParseURLNestedParameter) { |
571 TemplateURLRef url_ref("{%s", 0, 0); | 573 TemplateURLRef url_ref("{%s", 0, 0); |
572 TemplateURLRef::Replacements replacements; | 574 TemplateURLRef::Replacements replacements; |
573 bool valid = false; | 575 bool valid = false; |
574 EXPECT_EQ("{", url_ref.ParseURL("{{searchTerms}", &replacements, &valid)); | 576 EXPECT_EQ("{", url_ref.ParseURL("{{searchTerms}", &replacements, &valid)); |
575 ASSERT_EQ(1U, replacements.size()); | 577 ASSERT_EQ(1U, replacements.size()); |
576 EXPECT_EQ(static_cast<size_t>(1), replacements[0].index); | 578 EXPECT_EQ(static_cast<size_t>(1), replacements[0].index); |
577 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); | 579 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); |
578 EXPECT_TRUE(valid); | 580 EXPECT_TRUE(valid); |
579 } | 581 } |
OLD | NEW |