| Index: chrome/common/content_settings_pattern_unittest.cc
|
| diff --git a/chrome/common/content_settings_pattern_unittest.cc b/chrome/common/content_settings_pattern_unittest.cc
|
| index f56e87792c401cc2cbb844fd5150b4c3fe9c9f48..c91974e7ce09d53a0429c42d78bcb1edd43c8d3c 100644
|
| --- a/chrome/common/content_settings_pattern_unittest.cc
|
| +++ b/chrome/common/content_settings_pattern_unittest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/common/content_settings_pattern.h"
|
|
|
| +#include "chrome/common/content_settings_component.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "url/gurl.h"
|
|
|
| @@ -15,13 +16,23 @@ ContentSettingsPattern Pattern(const std::string& str) {
|
|
|
| } // namespace
|
|
|
| -TEST(ContentSettingsPatternTest, RealWorldPatterns) {
|
| +class ContentSettingsPatternTest : public testing::Test {
|
| + protected:
|
| + ContentSettingsPatternTest() {
|
| + InitContentSettingsComponent();
|
| + }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(ContentSettingsPatternTest);
|
| +};
|
| +
|
| +TEST_F(ContentSettingsPatternTest, RealWorldPatterns) {
|
| // This is the place for real world patterns that unveiled bugs.
|
| EXPECT_STREQ("[*.]ikea.com",
|
| Pattern("[*.]ikea.com").ToString().c_str());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, GURL) {
|
| +TEST_F(ContentSettingsPatternTest, GURL) {
|
| // Document and verify GURL behavior.
|
| GURL url("http://mail.google.com:80");
|
| EXPECT_EQ(-1, url.IntPort());
|
| @@ -44,7 +55,7 @@ TEST(ContentSettingsPatternTest, GURL) {
|
| EXPECT_EQ("", url.port());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FromURL) {
|
| +TEST_F(ContentSettingsPatternTest, FromURL) {
|
| // NOTICE: When content settings pattern are created from a GURL the following
|
| // happens:
|
| // - If the GURL scheme is "http" the scheme wildcard is used. Otherwise the
|
| @@ -90,7 +101,7 @@ TEST(ContentSettingsPatternTest, FromURL) {
|
| EXPECT_EQ("file:///foo/bar.html", pattern.ToString());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FilesystemUrls) {
|
| +TEST_F(ContentSettingsPatternTest, FilesystemUrls) {
|
| ContentSettingsPattern pattern =
|
| ContentSettingsPattern::FromURL(GURL("http://www.google.com"));
|
| EXPECT_TRUE(pattern.Matches(
|
| @@ -133,7 +144,7 @@ TEST(ContentSettingsPatternTest, FilesystemUrls) {
|
| EXPECT_EQ(ContentSettingsPattern::IDENTITY, pattern.Compare(pattern2));
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FromURLNoWildcard) {
|
| +TEST_F(ContentSettingsPatternTest, FromURLNoWildcard) {
|
| // If no port is specifed GURLs always use the default port for the schemes
|
| // HTTP and HTTPS. Hence a GURL always carries a port specification either
|
| // explicitly or implicitly. Therefore if a content settings pattern is
|
| @@ -175,7 +186,7 @@ TEST(ContentSettingsPatternTest, FromURLNoWildcard) {
|
| GURL("filesystem:https://foo.www.google.com/temporary/")));
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, Wildcard) {
|
| +TEST_F(ContentSettingsPatternTest, Wildcard) {
|
| EXPECT_TRUE(ContentSettingsPattern::Wildcard().IsValid());
|
|
|
| EXPECT_TRUE(ContentSettingsPattern::Wildcard().Matches(
|
| @@ -194,7 +205,7 @@ TEST(ContentSettingsPatternTest, Wildcard) {
|
| ContentSettingsPattern::Wildcard()));
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, TrimEndingDotFromHost) {
|
| +TEST_F(ContentSettingsPatternTest, TrimEndingDotFromHost) {
|
| EXPECT_TRUE(Pattern("www.example.com").IsValid());
|
| EXPECT_TRUE(Pattern("www.example.com").Matches(
|
| GURL("http://www.example.com")));
|
| @@ -211,7 +222,7 @@ TEST(ContentSettingsPatternTest, TrimEndingDotFromHost) {
|
| EXPECT_STREQ(".", Pattern(".").ToString().c_str());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FromString_WithNoWildcards) {
|
| +TEST_F(ContentSettingsPatternTest, FromString_WithNoWildcards) {
|
| // HTTP patterns with default port.
|
| EXPECT_TRUE(Pattern("http://www.example.com:80").IsValid());
|
| EXPECT_STREQ("http://www.example.com:80",
|
| @@ -231,7 +242,7 @@ TEST(ContentSettingsPatternTest, FromString_WithNoWildcards) {
|
| Pattern("https://www.example.com:8080").ToString().c_str());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FromString_FilePatterns) {
|
| +TEST_F(ContentSettingsPatternTest, FromString_FilePatterns) {
|
| // "/" is an invalid file path.
|
| EXPECT_FALSE(Pattern("file:///").IsValid());
|
|
|
| @@ -272,7 +283,7 @@ TEST(ContentSettingsPatternTest, FromString_FilePatterns) {
|
| GURL("file://localhost/tmp/test.html")));
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FromString_ExtensionPatterns) {
|
| +TEST_F(ContentSettingsPatternTest, FromString_ExtensionPatterns) {
|
| EXPECT_TRUE(Pattern("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/")
|
| .IsValid());
|
| EXPECT_EQ("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/",
|
| @@ -282,7 +293,7 @@ TEST(ContentSettingsPatternTest, FromString_ExtensionPatterns) {
|
| .Matches(GURL("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel/")));
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FromString_WithIPAdresses) {
|
| +TEST_F(ContentSettingsPatternTest, FromString_WithIPAdresses) {
|
| // IPv4
|
| EXPECT_TRUE(Pattern("192.168.0.1").IsValid());
|
| EXPECT_STREQ("192.168.1.1", Pattern("192.168.1.1").ToString().c_str());
|
| @@ -301,7 +312,7 @@ TEST(ContentSettingsPatternTest, FromString_WithIPAdresses) {
|
| Pattern("https://[::1]:8080").ToString().c_str());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FromString_WithWildcards) {
|
| +TEST_F(ContentSettingsPatternTest, FromString_WithWildcards) {
|
| // Creating content settings patterns from strings completes pattern parts
|
| // that are omitted in pattern specifications (strings) with a wildcard.
|
|
|
| @@ -396,7 +407,7 @@ TEST(ContentSettingsPatternTest, FromString_WithWildcards) {
|
| EXPECT_STREQ("*", Pattern("*://*").ToString().c_str());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, FromString_Canonicalized) {
|
| +TEST_F(ContentSettingsPatternTest, FromString_Canonicalized) {
|
| // UTF-8 patterns.
|
| EXPECT_TRUE(Pattern("[*.]\xC4\x87ira.com").IsValid());
|
| EXPECT_STREQ("[*.]xn--ira-ppa.com",
|
| @@ -414,7 +425,7 @@ TEST(ContentSettingsPatternTest, FromString_Canonicalized) {
|
| Pattern("file:///tmp/bar/../test.html").ToString().c_str());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, InvalidPatterns) {
|
| +TEST_F(ContentSettingsPatternTest, InvalidPatterns) {
|
| // StubObserver expects an empty pattern top be returned as empty string.
|
| EXPECT_FALSE(ContentSettingsPattern().IsValid());
|
| EXPECT_STREQ("", ContentSettingsPattern().ToString().c_str());
|
| @@ -452,7 +463,7 @@ TEST(ContentSettingsPatternTest, InvalidPatterns) {
|
| EXPECT_STREQ("", Pattern("www.example.com..").ToString().c_str());
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, UnequalOperator) {
|
| +TEST_F(ContentSettingsPatternTest, UnequalOperator) {
|
| EXPECT_TRUE(Pattern("http://www.foo.com") != Pattern("http://www.foo.com*"));
|
| EXPECT_TRUE(Pattern("http://www.foo.com*") !=
|
| ContentSettingsPattern::Wildcard());
|
| @@ -468,7 +479,7 @@ TEST(ContentSettingsPatternTest, UnequalOperator) {
|
| EXPECT_TRUE(Pattern("http://www.foo.com") == Pattern("http://www.foo.com"));
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, Compare) {
|
| +TEST_F(ContentSettingsPatternTest, Compare) {
|
| // Test identical patterns patterns.
|
| ContentSettingsPattern pattern1 =
|
| Pattern("http://www.google.com");
|
| @@ -606,7 +617,7 @@ TEST(ContentSettingsPatternTest, Compare) {
|
|
|
| // Legacy tests to ensure backwards compatibility.
|
|
|
| -TEST(ContentSettingsPatternTest, PatternSupport_Legacy) {
|
| +TEST_F(ContentSettingsPatternTest, PatternSupport_Legacy) {
|
| EXPECT_TRUE(Pattern("[*.]example.com").IsValid());
|
| EXPECT_TRUE(Pattern("example.com").IsValid());
|
| EXPECT_TRUE(Pattern("192.168.0.1").IsValid());
|
| @@ -643,7 +654,7 @@ TEST(ContentSettingsPatternTest, PatternSupport_Legacy) {
|
| GURL("http://example.org/")));
|
| }
|
|
|
| -TEST(ContentSettingsPatternTest, CanonicalizePattern_Legacy) {
|
| +TEST_F(ContentSettingsPatternTest, CanonicalizePattern_Legacy) {
|
| // Basic patterns.
|
| EXPECT_STREQ("[*.]ikea.com", Pattern("[*.]ikea.com").ToString().c_str());
|
| EXPECT_STREQ("example.com", Pattern("example.com").ToString().c_str());
|
|
|