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

Unified Diff: components/url_matcher/url_matcher_unittest.cc

Issue 219613002: Add support for matching query parameters in URLMatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Makes the changes backward compatible Created 6 years, 9 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/url_matcher/url_matcher_unittest.cc
diff --git a/components/url_matcher/url_matcher_unittest.cc b/components/url_matcher/url_matcher_unittest.cc
index 748d3101352d9e86d1bd5009811028eb22233c37..a7b8e49467c5e131f95f5002a9cd44360c97ad01 100644
--- a/components/url_matcher/url_matcher_unittest.cc
+++ b/components/url_matcher/url_matcher_unittest.cc
@@ -69,8 +69,8 @@ TEST(URLMatcherConditionTest, IsFullURLCondition) {
&pattern).IsFullURLCondition());
EXPECT_TRUE(URLMatcherCondition(URLMatcherCondition::PATH_CONTAINS,
&pattern).IsFullURLCondition());
- EXPECT_TRUE(URLMatcherCondition(URLMatcherCondition::QUERY_CONTAINS,
- &pattern).IsFullURLCondition());
+ EXPECT_FALSE(URLMatcherCondition(URLMatcherCondition::QUERY_CONTAINS,
+ &pattern).IsFullURLCondition());
EXPECT_TRUE(URLMatcherCondition(URLMatcherCondition::URL_PREFIX,
&pattern).IsFullURLCondition());
@@ -326,6 +326,42 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
EXPECT_FALSE(
Matches(factory.CreateQueryEqualsCondition("www.google.com"), url));
+ EXPECT_TRUE(Matches(
+ factory.CreateQueryContainsCondition("sourceid=chrome-instant"), url));
+ // The '?' at the beginning is just ignored.
+ EXPECT_TRUE(Matches(
+ factory.CreateQueryContainsCondition("?sourceid=chrome-instant"), url));
+ EXPECT_TRUE(Matches(factory.CreateQueryContainsCondition("?ie=UTF-8"), url));
+ EXPECT_TRUE(Matches(factory.CreateQueryContainsCondition("ie=UTF-8"), url));
+ EXPECT_TRUE(Matches(factory.CreateQueryContainsCondition("t&ie=UTF-8"), url));
+ EXPECT_TRUE(Matches(factory.CreateQueryContainsCondition("e=UTF-8"), url));
+ // Multiple key value pairs are supported (though not very useful)
+ EXPECT_TRUE(Matches(
+ factory.CreateQueryContainsCondition("sourceid=chrome-instant&ie=UTF-8"),
+ url));
+
+ EXPECT_TRUE(Matches(
+ factory.CreateQueryContainsExactCondition("sourceid=chrome-instant"),
+ url));
+ // The '?' at the beginning is just ignored.
+ EXPECT_TRUE(Matches(
+ factory.CreateQueryContainsExactCondition("?sourceid=chrome-instant"),
+ url));
+ EXPECT_TRUE(
+ Matches(factory.CreateQueryContainsExactCondition("?ie=UTF-8"), url));
+ EXPECT_TRUE(
+ Matches(factory.CreateQueryContainsExactCondition("ie=UTF-8"), url));
+ // Partial key value pairs not supported
+ EXPECT_FALSE(
+ Matches(factory.CreateQueryContainsExactCondition("t&ie=UTF-8"), url));
+ // Looks for an exact match, i.e., looks for "&e=UTF-8" or "?e=UTF-8" below
+ // and fails.
+ EXPECT_FALSE(
+ Matches(factory.CreateQueryContainsExactCondition("e=UTF-8"), url));
+ // Multiple key value pairs are supported (though not very useful)
+ EXPECT_TRUE(Matches(factory.CreateQueryContainsExactCondition(
+ "sourceid=chrome-instant&ie=UTF-8"),
+ url));
// Test adjacent components
EXPECT_TRUE(Matches(factory.CreateHostSuffixPathPrefixCondition(
« components/url_matcher/url_matcher.cc ('K') | « components/url_matcher/url_matcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698