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

Unified Diff: chrome/common/extensions/url_pattern_unittest.cc

Issue 7347011: Update URLPatternSet to contain a std::set instead of std::vector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows compile errors. Created 9 years, 5 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
« no previous file with comments | « chrome/common/extensions/url_pattern_set_unittest.cc ('k') | chrome/common/extensions/user_script.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/url_pattern_unittest.cc
diff --git a/chrome/common/extensions/url_pattern_unittest.cc b/chrome/common/extensions/url_pattern_unittest.cc
index 090339521e7ecbef34bbbc441e8ef86c1be56cc8..5c72a058d558fb899da9a861ae4dfd1a4b94f3cc 100644
--- a/chrome/common/extensions/url_pattern_unittest.cc
+++ b/chrome/common/extensions/url_pattern_unittest.cc
@@ -580,3 +580,97 @@ TEST(ExtensionURLPatternTest, IgnorePorts) {
EXPECT_FALSE(pattern1.MatchesURL(url));
EXPECT_FALSE(pattern2.MatchesURL(url));
}
+
+TEST(ExtensionURLPatternTest, Equals) {
+ const struct {
+ const char* pattern1;
+ const char* pattern2;
+ bool expected_equal;
+ } kEqualsTestCases[] = {
+ // schemes
+ { "http://en.google.com/blah/*/foo",
+ "https://en.google.com/blah/*/foo",
+ false
+ },
+ { "https://en.google.com/blah/*/foo",
+ "https://en.google.com/blah/*/foo",
+ true
+ },
+ { "https://en.google.com/blah/*/foo",
+ "ftp://en.google.com/blah/*/foo",
+ false
+ },
+
+ // subdomains
+ { "https://en.google.com/blah/*/foo",
+ "https://fr.google.com/blah/*/foo",
+ false
+ },
+ { "https://www.google.com/blah/*/foo",
+ "https://*.google.com/blah/*/foo",
+ false
+ },
+ { "https://*.google.com/blah/*/foo",
+ "https://*.google.com/blah/*/foo",
+ true
+ },
+
+ // domains
+ { "http://en.example.com/blah/*/foo",
+ "http://en.google.com/blah/*/foo",
+ false
+ },
+
+ // ports
+ { "http://en.google.com:8000/blah/*/foo",
+ "http://en.google.com/blah/*/foo",
+ false
+ },
+ { "http://fr.google.com:8000/blah/*/foo",
+ "http://fr.google.com:8000/blah/*/foo",
+ true
+ },
+ { "http://en.google.com:8000/blah/*/foo",
+ "http://en.google.com:8080/blah/*/foo",
+ false
+ },
+
+ // paths
+ { "http://en.google.com/blah/*/foo",
+ "http://en.google.com/blah/*",
+ false
+ },
+ { "http://en.google.com/*",
+ "http://en.google.com/",
+ false
+ },
+ { "http://en.google.com/*",
+ "http://en.google.com/*",
+ true
+ },
+
+ // all_urls
+ { "<all_urls>",
+ "<all_urls>",
+ true
+ },
+ { "<all_urls>",
+ "http://*/*",
+ false
+ }
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kEqualsTestCases); ++i) {
+ std::string message = kEqualsTestCases[i].pattern1;
+ message += " ";
+ message += kEqualsTestCases[i].pattern2;
+
+ URLPattern pattern1(URLPattern::SCHEME_ALL);
+ URLPattern pattern2(URLPattern::SCHEME_ALL);
+
+ pattern1.Parse(kEqualsTestCases[i].pattern1, URLPattern::USE_PORTS);
+ pattern2.Parse(kEqualsTestCases[i].pattern2, URLPattern::USE_PORTS);
+ EXPECT_EQ(kEqualsTestCases[i].expected_equal, pattern1 == pattern2)
+ << message;
+ }
+}
« no previous file with comments | « chrome/common/extensions/url_pattern_set_unittest.cc ('k') | chrome/common/extensions/user_script.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698