Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4988)

Unified Diff: chrome/browser/search_engines/template_url_unittest.cc

Issue 7230053: Modify TemplateURLRef to remove unknown URL parameters, but only when it represents a prepopulate... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/template_url_unittest.cc
===================================================================
--- chrome/browser/search_engines/template_url_unittest.cc (revision 90805)
+++ chrome/browser/search_engines/template_url_unittest.cc (working copy)
@@ -151,6 +151,29 @@
ASSERT_EQ("http://fooxxutf-8ya/", result.spec());
}
+TEST_F(TemplateURLTest, SetPrepopulatedAndParse) {
sky 2011/06/28 21:02:26 Add a description of what this is testing.
+ TemplateURL t_url;
+ t_url.SetURL("http://foo{fhqwhgads}", 0, 0);
+ TemplateURLRef::Replacements replacements;
+ bool valid = false;
+
+ t_url.SetPrepopulateId(0);
+ EXPECT_EQ("http://foo{fhqwhgads}",
+ t_url.url()->ParseURL("http://foo{fhqwhgads}",
+ &replacements,
+ &valid));
+ EXPECT_TRUE(replacements.empty());
+ EXPECT_TRUE(valid);
+
+ t_url.SetPrepopulateId(123);
+ EXPECT_EQ("http://foo",
+ t_url.url()->ParseURL("http://foo{fhqwhgads}",
+ &replacements,
+ &valid));
+ EXPECT_TRUE(replacements.empty());
+ EXPECT_TRUE(valid);
+}
+
TEST_F(TemplateURLTest, InputEncodingBeforeSearchTerm) {
TemplateURL t_url;
TemplateURLRef ref(
@@ -486,12 +509,22 @@
}
TEST_F(TemplateURLTest, ParseParameterUnknown) {
- std::string parsed_url("{}");
+ std::string parsed_url("{fhqwhgads}");
TemplateURLRef url_ref(parsed_url, 0, 0);
TemplateURLRef::Replacements replacements;
- EXPECT_FALSE(url_ref.ParseParameter(0, 1, &parsed_url, &replacements));
- EXPECT_EQ("{}", parsed_url);
+
+ // By default, TemplateURLRef should not consider itself prepopulated.
+ // Therefore we should not replace the unknown parameter.
+ EXPECT_FALSE(url_ref.ParseParameter(0, 10, &parsed_url, &replacements));
+ EXPECT_EQ("{fhqwhgads}", parsed_url);
EXPECT_TRUE(replacements.empty());
+
+ // If the TemplateURLRef is prepopulated, we should remove unknown parameters.
+ parsed_url = "{fhqwhgads}";
+ url_ref.set_prepopulated(true);
+ EXPECT_FALSE(url_ref.ParseParameter(0, 10, &parsed_url, &replacements));
+ EXPECT_EQ("", parsed_url);
+ EXPECT_TRUE(replacements.empty());
}
TEST_F(TemplateURLTest, ParseURLEmpty) {

Powered by Google App Engine
This is Rietveld 408576698