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

Side by Side Diff: chrome/common/content_settings_pattern_unittest.cc

Issue 13251012: Fix b180514: Some exception entries cannot be deleted from a setting panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring Created 7 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/content_settings_pattern.h" 5 #include "chrome/common/content_settings_pattern.h"
6 6
7 #include "googleurl/src/gurl.h" 7 #include "googleurl/src/gurl.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.example.com"))); 151 EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.example.com")));
152 152
153 pattern = ContentSettingsPattern::FromURLNoWildcard( 153 pattern = ContentSettingsPattern::FromURLNoWildcard(
154 GURL("https://www.example.com")); 154 GURL("https://www.example.com"));
155 EXPECT_TRUE(pattern.IsValid()); 155 EXPECT_TRUE(pattern.IsValid());
156 EXPECT_STREQ("https://www.example.com:443", pattern.ToString().c_str()); 156 EXPECT_STREQ("https://www.example.com:443", pattern.ToString().c_str());
157 EXPECT_FALSE(pattern.Matches(GURL("http://www.example.com"))); 157 EXPECT_FALSE(pattern.Matches(GURL("http://www.example.com")));
158 EXPECT_TRUE(pattern.Matches(GURL("https://www.example.com"))); 158 EXPECT_TRUE(pattern.Matches(GURL("https://www.example.com")));
159 EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.example.com"))); 159 EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.example.com")));
160 160
161 // Pattern for filesystem URLs 161 // Pattern for filesystem URLs
162 pattern = 162 pattern =
163 ContentSettingsPattern::FromURLNoWildcard( 163 ContentSettingsPattern::FromURLNoWildcard(
164 GURL("filesystem:http://www.google.com/temporary/")); 164 GURL("filesystem:http://www.google.com/temporary/"));
165 EXPECT_TRUE(pattern.IsValid()); 165 EXPECT_TRUE(pattern.IsValid());
166 EXPECT_TRUE(pattern.Matches(GURL("http://www.google.com"))); 166 EXPECT_TRUE(pattern.Matches(GURL("http://www.google.com")));
167 EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.google.com"))); 167 EXPECT_FALSE(pattern.Matches(GURL("http://foo.www.google.com")));
168 EXPECT_TRUE(pattern.Matches( 168 EXPECT_TRUE(pattern.Matches(
169 GURL("filesystem:http://www.google.com/persistent/"))); 169 GURL("filesystem:http://www.google.com/persistent/")));
170 EXPECT_FALSE(pattern.Matches( 170 EXPECT_FALSE(pattern.Matches(
171 GURL("filesystem:https://www.google.com/persistent/"))); 171 GURL("filesystem:https://www.google.com/persistent/")));
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 // Pattern strings with invalid port parts. 437 // Pattern strings with invalid port parts.
438 EXPECT_FALSE(Pattern("example.com:abc").IsValid()); 438 EXPECT_FALSE(Pattern("example.com:abc").IsValid());
439 EXPECT_STREQ("", Pattern("example.com:abc").ToString().c_str()); 439 EXPECT_STREQ("", Pattern("example.com:abc").ToString().c_str());
440 440
441 // Invalid file pattern strings. 441 // Invalid file pattern strings.
442 EXPECT_FALSE(Pattern("file://").IsValid()); 442 EXPECT_FALSE(Pattern("file://").IsValid());
443 EXPECT_STREQ("", Pattern("file://").ToString().c_str()); 443 EXPECT_STREQ("", Pattern("file://").ToString().c_str());
444 EXPECT_FALSE(Pattern("file:///foo/bar.html:8080").IsValid()); 444 EXPECT_FALSE(Pattern("file:///foo/bar.html:8080").IsValid());
445 EXPECT_STREQ("", Pattern("file:///foo/bar.html:8080").ToString().c_str()); 445 EXPECT_STREQ("", Pattern("file:///foo/bar.html:8080").ToString().c_str());
446
447 EXPECT_FALSE(Pattern(".").IsValid());
448 EXPECT_STREQ("", Pattern(".").ToString().c_str());
449
450 // Host having consecutive dots.
451 EXPECT_FALSE(Pattern("www.example.com..").IsValid());
452 EXPECT_STREQ("", Pattern("www.example.com..").ToString().c_str());
453 EXPECT_FALSE(Pattern("www..example.com").IsValid());
454 EXPECT_STREQ("", Pattern("www..example.com").ToString().c_str());
446 } 455 }
447 456
448 TEST(ContentSettingsPatternTest, UnequalOperator) { 457 TEST(ContentSettingsPatternTest, UnequalOperator) {
449 EXPECT_TRUE(Pattern("http://www.foo.com") != Pattern("http://www.foo.com*")); 458 EXPECT_TRUE(Pattern("http://www.foo.com") != Pattern("http://www.foo.com*"));
450 EXPECT_TRUE(Pattern("http://www.foo.com*") != 459 EXPECT_TRUE(Pattern("http://www.foo.com*") !=
451 ContentSettingsPattern::Wildcard()); 460 ContentSettingsPattern::Wildcard());
452 461
453 EXPECT_TRUE(Pattern("http://www.foo.com") != 462 EXPECT_TRUE(Pattern("http://www.foo.com") !=
454 ContentSettingsPattern::Wildcard()); 463 ContentSettingsPattern::Wildcard());
455 464
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // file:/// normalization. 666 // file:/// normalization.
658 EXPECT_STREQ("file:///tmp/test.html", 667 EXPECT_STREQ("file:///tmp/test.html",
659 Pattern("file:///tmp/bar/../test.html").ToString().c_str()); 668 Pattern("file:///tmp/bar/../test.html").ToString().c_str());
660 669
661 // Invalid patterns. 670 // Invalid patterns.
662 EXPECT_STREQ("", Pattern("*example.com").ToString().c_str()); 671 EXPECT_STREQ("", Pattern("*example.com").ToString().c_str());
663 EXPECT_STREQ("", Pattern("example.*").ToString().c_str()); 672 EXPECT_STREQ("", Pattern("example.*").ToString().c_str());
664 EXPECT_STREQ("", Pattern("*\xC4\x87ira.com").ToString().c_str()); 673 EXPECT_STREQ("", Pattern("*\xC4\x87ira.com").ToString().c_str());
665 EXPECT_STREQ("", Pattern("\xC4\x87ira.*").ToString().c_str()); 674 EXPECT_STREQ("", Pattern("\xC4\x87ira.*").ToString().c_str());
666 } 675 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698