| 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..f269e0f22549d42c529625da7d4498a55a84a10e 100644
|
| --- a/components/search_engines/template_url_unittest.cc
|
| +++ b/components/search_engines/template_url_unittest.cc
|
| @@ -778,23 +778,23 @@ TEST_F(TemplateURLTest, HostAndSearchTermKey) {
|
| const std::string path;
|
| const std::string search_term_key;
|
| } test_data[] = {
|
| - { "http://blah/?foo=bar&q={searchTerms}&b=x", "blah", "/", "q"},
|
| - { "http://blah/{searchTerms}", "blah", "/", ""},
|
| + {"http://blah/?foo=bar&q={searchTerms}&b=x", "blah", "/", "q"},
|
| + {"http://blah/{searchTerms}", "blah", "", ""},
|
|
|
| - // No term should result in empty values.
|
| - { "http://blah/", "", "", ""},
|
| + // No term should result in empty values.
|
| + {"http://blah/", "", "", ""},
|
|
|
| - // Multiple terms should result in empty values.
|
| - { "http://blah/?q={searchTerms}&x={searchTerms}", "", "", ""},
|
| + // Multiple terms should result in empty values.
|
| + {"http://blah/?q={searchTerms}&x={searchTerms}", "", "", ""},
|
|
|
| - // Term in the host shouldn't match.
|
| - { "http://{searchTerms}", "", "", ""},
|
| + // Term in the host shouldn't match.
|
| + {"http://{searchTerms}", "", "", ""},
|
|
|
| - { "http://blah/?q={searchTerms}", "blah", "/", "q"},
|
| - { "https://blah/?q={searchTerms}", "blah", "/", "q"},
|
| + {"http://blah/?q={searchTerms}", "blah", "/", "q"},
|
| + {"https://blah/?q={searchTerms}", "blah", "/", "q"},
|
|
|
| - // Single term with extra chars in value should match.
|
| - { "http://blah/?q=stock:{searchTerms}", "blah", "/", "q"},
|
| + // Single term with extra chars in value should match.
|
| + {"http://blah/?q=stock:{searchTerms}", "blah", "/", "q"},
|
| };
|
|
|
| for (size_t i = 0; i < arraysize(test_data); ++i) {
|
| @@ -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_));
|
| }
|
| }
|
|
|
|
|