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

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

Issue 7003098: Start refractoring extension permissions into ExtensionPermissionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: See if rebasing fixes the tests... 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
« no previous file with comments | « chrome/common/extensions/url_pattern_set.cc ('k') | chrome/renderer/extensions/bindings_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/url_pattern_set_unittest.cc
diff --git a/chrome/common/extensions/url_pattern_set_unittest.cc b/chrome/common/extensions/url_pattern_set_unittest.cc
index 5336410963a7329d989e75498e6e619b8317ac61..8c05f2c705353da53725f8526a719cf163002e20 100644
--- a/chrome/common/extensions/url_pattern_set_unittest.cc
+++ b/chrome/common/extensions/url_pattern_set_unittest.cc
@@ -7,6 +7,27 @@
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace {
+
+static void AssertEqualExtents(const URLPatternSet& extent1,
+ const URLPatternSet& extent2) {
+ URLPatternList patterns1 = extent1.patterns();
+ URLPatternList patterns2 = extent2.patterns();
+ std::set<std::string> strings1;
+ EXPECT_EQ(patterns1.size(), patterns2.size());
+
+ for (size_t i = 0; i < patterns1.size(); ++i)
+ strings1.insert(patterns1.at(i).GetAsString());
+
+ std::set<std::string> strings2;
+ for (size_t i = 0; i < patterns2.size(); ++i)
+ strings2.insert(patterns2.at(i).GetAsString());
+
+ EXPECT_EQ(strings1, strings2);
+}
+
+} // namespace
+
static const int kAllSchemes =
URLPattern::SCHEME_HTTP |
URLPattern::SCHEME_HTTPS |
@@ -60,3 +81,35 @@ TEST(URLPatternSetTest, OverlapsWith) {
EXPECT_TRUE(extent1.OverlapsWith(extent3));
EXPECT_TRUE(extent3.OverlapsWith(extent1));
}
+
+TEST(URLPatternSetTest, CreateUnion) {
+ URLPatternSet empty_extent;
+
+ URLPatternSet extent1;
+ extent1.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/f*"));
+ extent1.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/b*"));
+
+ URLPatternSet expected;
+ expected.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/f*"));
+ expected.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/b*"));
+
+ // Union with an empty set.
+ URLPatternSet result;
+ URLPatternSet::CreateUnion(extent1, empty_extent, &result);
+ AssertEqualExtents(expected, result);
+
+ // Union with a real set (including a duplicate).
+ URLPatternSet extent2;
+ extent2.AddPattern(URLPattern(kAllSchemes, "http://www.reddit.com/f*"));
+ extent2.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/z*"));
+ extent2.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/f*"));
+
+ expected.AddPattern(URLPattern(kAllSchemes, "http://www.reddit.com/f*"));
+ expected.AddPattern(URLPattern(kAllSchemes, "http://www.yahoo.com/z*"));
+ // CreateUnion does not filter out duplicates right now.
+ expected.AddPattern(URLPattern(kAllSchemes, "http://www.google.com/f*"));
+
+ result.ClearPatterns();
+ URLPatternSet::CreateUnion(extent1, extent2, &result);
+ AssertEqualExtents(expected, result);
+}
« no previous file with comments | « chrome/common/extensions/url_pattern_set.cc ('k') | chrome/renderer/extensions/bindings_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698