diff options
Diffstat (limited to 'chrome/common/extensions/extension_extent_unittest.cc')
-rw-r--r-- | chrome/common/extensions/extension_extent_unittest.cc | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/chrome/common/extensions/extension_extent_unittest.cc b/chrome/common/extensions/extension_extent_unittest.cc index 41f2d15..4e308fa 100644 --- a/chrome/common/extensions/extension_extent_unittest.cc +++ b/chrome/common/extensions/extension_extent_unittest.cc @@ -14,22 +14,44 @@ TEST(ExtensionExtentTest, Empty) { EXPECT_FALSE(extent.ContainsURL(GURL("invalid"))); } -TEST(ExtensionExtentTest, One) { +TEST(ExtensionExtentTest, OriginOnly) { ExtensionExtent extent; - extent.AddPattern(*URLPattern::CreateFromString("http://www.google.com/*")); + extent.set_origin(GURL("http://www.google.com/")); EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/"))); - EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/foo"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/foobar"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/foo/bar"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/?stuff#here"))); + EXPECT_FALSE(extent.ContainsURL(GURL("https://www.google.com/"))); - EXPECT_FALSE(extent.ContainsURL(GURL("https://www.microsoft.com/"))); + EXPECT_FALSE(extent.ContainsURL(GURL("http://www.google.com:8080/"))); } -TEST(ExtensionExtentTest, Two) { +TEST(ExtensionExtentTest, OriginAndOnePath) { ExtensionExtent extent; - extent.AddPattern(*URLPattern::CreateFromString("http://www.google.com/*")); - extent.AddPattern(*URLPattern::CreateFromString("http://www.yahoo.com/*")); + extent.set_origin(GURL("http://www.google.com/")); + extent.add_path("foo"); + + EXPECT_FALSE(extent.ContainsURL(GURL("http://www.google.com/"))); + EXPECT_FALSE(extent.ContainsURL(GURL("http://www.google.com/fo"))); + + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/foo"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/FOO"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/foobar"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/foo/bar"))); +} + +TEST(ExtensionExtentTest, OriginAndTwoPaths) { + ExtensionExtent extent; + extent.set_origin(GURL("http://www.google.com/")); + extent.add_path("foo"); + extent.add_path("hot"); + + EXPECT_FALSE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); - EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/monkey"))); - EXPECT_TRUE(extent.ContainsURL(GURL("http://www.yahoo.com/monkey"))); - EXPECT_FALSE(extent.ContainsURL(GURL("https://www.apple.com/monkey"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/foo"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/hot"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/foobar"))); + EXPECT_TRUE(extent.ContainsURL(GURL("http://www.google.com/hotdog"))); } |