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

Unified Diff: components/search_engines/template_url_unittest.cc

Issue 2877983002: Use search_term_value_prefix_ & search_term_value_suffix_ to specify the location of {searchTerms} … (Closed)
Patch Set: Created 3 years, 7 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: components/search_engines/template_url_unittest.cc
diff --git a/components/search_engines/template_url_unittest.cc b/components/search_engines/template_url_unittest.cc
index 2b83148518a09c8a654ad7bae0ee9b7fb5f21707..2b56cf60c6c00519e584ae76466bf6fdad07349e 100644
--- a/components/search_engines/template_url_unittest.cc
+++ b/components/search_engines/template_url_unittest.cc
@@ -813,28 +813,33 @@ TEST_F(TemplateURLTest, SearchTermKeyLocation) {
const std::string url;
const url::Parsed::ComponentType location;
const std::string path;
- size_t position_in_path;
+ const std::string key;
+ const std::string value_prefix;
+ const std::string value_suffix;
} test_data[] = {
- { "http://blah/{searchTerms}/", url::Parsed::PATH, "//", 1 },
- { "http://blah/{searchTerms}", url::Parsed::PATH, "/", 1 },
- { "http://blah/begin/{searchTerms}/end", url::Parsed::PATH, "/begin//end", 7 },
-
- { "http://blah/?foo=bar&q={searchTerms}&b=x", url::Parsed::QUERY,
- "/", std::string::npos },
- { "http://blah/?foo=bar#x={searchTerms}&b=x", url::Parsed::REF,
- "/", std::string::npos },
- // searchTerms is a key, not a value, so this should result in an empty
- // value.
- { "http://blah/?foo=bar#x=012345678901234&a=b&{searchTerms}=x",
- url::Parsed::QUERY, std::string(), std::string::npos },
-
- // Multiple search terms should result in empty values.
- { "http://blah/{searchTerms}?q={searchTerms}", url::Parsed::QUERY,
- "", std::string::npos },
- { "http://blah/{searchTerms}#x={searchTerms}", url::Parsed::QUERY,
- "", std::string::npos },
- { "http://blah/?q={searchTerms}#x={searchTerms}", url::Parsed::QUERY,
- "", std::string::npos },
+ {"http://blah/{searchTerms}/", url::Parsed::PATH, "", "", "/", "/"},
+ {"http://blah/{searchTerms}", url::Parsed::PATH, "", "", "/", ""},
+ {"http://blah/begin/{searchTerms}/end", url::Parsed::PATH, "", "",
+ "/begin/", "/end"},
+ {"http://blah/?foo=bar&q={searchTerms}&b=x", url::Parsed::QUERY, "/", "q",
+ "", ""},
+ {"http://blah/?foo=bar#x={searchTerms}&b=x", url::Parsed::REF, "/", "x",
+ "", ""},
+ {"http://www.example.com/?q=chromium-{searchTerms}@chromium.org/info",
+ url::Parsed::QUERY, "/", "q", "chromium-", "@chromium.org/info"},
+
+ // searchTerms is a key, not a value, so this should result in an empty
+ // value.
+ {"http://blah/?foo=bar#x=012345678901234&a=b&{searchTerms}=x",
+ url::Parsed::QUERY, "", "", "", ""},
+
+ // Multiple search terms should result in empty values.
+ {"http://blah/{searchTerms}?q={searchTerms}", url::Parsed::QUERY, "", "",
+ "", ""},
+ {"http://blah/{searchTerms}#x={searchTerms}", url::Parsed::QUERY, "", "",
+ "", ""},
+ {"http://blah/?q={searchTerms}#x={searchTerms}", url::Parsed::QUERY, "",
+ "", "", ""},
};
for (size_t i = 0; i < arraysize(test_data); ++i) {
@@ -845,8 +850,12 @@ TEST_F(TemplateURLTest, SearchTermKeyLocation) {
url.url_ref().GetSearchTermKeyLocation(search_terms_data_));
EXPECT_EQ(test_data[i].path,
url.url_ref().GetPath(search_terms_data_));
- EXPECT_EQ(test_data[i].position_in_path,
- url.url_ref().GetSearchTermPositionInPath(search_terms_data_));
+ EXPECT_EQ(test_data[i].key,
+ url.url_ref().GetSearchTermKey(search_terms_data_));
+ EXPECT_EQ(test_data[i].value_prefix,
+ url.url_ref().GetSearchTermValuePrefix(search_terms_data_));
+ EXPECT_EQ(test_data[i].value_suffix,
+ url.url_ref().GetSearchTermValueSuffix(search_terms_data_));
}
}
« components/search_engines/template_url.cc ('K') | « components/search_engines/template_url.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698