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

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: 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 EXPECT_TRUE(ContentSettingsPattern::Wildcard().Matches( 187 EXPECT_TRUE(ContentSettingsPattern::Wildcard().Matches(
188 GURL("file:///foo/bar.txt"))); 188 GURL("file:///foo/bar.txt")));
189 189
190 EXPECT_STREQ("*", ContentSettingsPattern::Wildcard().ToString().c_str()); 190 EXPECT_STREQ("*", ContentSettingsPattern::Wildcard().ToString().c_str());
191 191
192 EXPECT_EQ(ContentSettingsPattern::IDENTITY, 192 EXPECT_EQ(ContentSettingsPattern::IDENTITY,
193 ContentSettingsPattern::Wildcard().Compare( 193 ContentSettingsPattern::Wildcard().Compare(
194 ContentSettingsPattern::Wildcard())); 194 ContentSettingsPattern::Wildcard()));
195 } 195 }
196 196
197 TEST(ContentSettingsPatternTest, TrimEndingDotFromHost) { 197 TEST(ContentSettingsPatternTest, TrimEndingDots) {
198 EXPECT_TRUE(Pattern("www.example.com").IsValid()); 198 EXPECT_TRUE(Pattern("www.example.com").IsValid());
199 EXPECT_TRUE(Pattern("www.example.com").Matches( 199 EXPECT_TRUE(Pattern("www.example.com").Matches(
200 GURL("http://www.example.com"))); 200 GURL("http://www.example.com")));
201 EXPECT_TRUE(Pattern("www.example.com").Matches( 201 EXPECT_TRUE(Pattern("www.example.com").Matches(
202 GURL("http://www.example.com."))); 202 GURL("http://www.example.com..")));
203 203
204 EXPECT_TRUE(Pattern("www.example.com.").IsValid()); 204 EXPECT_TRUE(Pattern("www.example.com..").IsValid());
205 EXPECT_STREQ("www.example.com", 205 EXPECT_STREQ("www.example.com",
206 Pattern("www.example.com.").ToString().c_str()); 206 Pattern("www.example.com..").ToString().c_str());
207 207
208 EXPECT_TRUE(Pattern("www.example.com.") == Pattern("www.example.com")); 208 EXPECT_TRUE(Pattern("www.example.com..") == Pattern("www.example.com"));
209 }
210
211 TEST(ContentSettingsPatternTest, TrimEndingDotsWithStringConsistsOfDots) {
212 EXPECT_TRUE(Pattern(".").IsValid());
213 EXPECT_TRUE(Pattern(".").Matches(GURL("http://.")));
214 EXPECT_TRUE(Pattern(".").Matches(GURL("http://..")));
215
216 EXPECT_TRUE(Pattern("..").IsValid());
217 EXPECT_STREQ(".", Pattern("..").ToString().c_str());
218
219 EXPECT_TRUE(Pattern("..") == Pattern("."));
209 } 220 }
210 221
211 TEST(ContentSettingsPatternTest, FromString_WithNoWildcards) { 222 TEST(ContentSettingsPatternTest, FromString_WithNoWildcards) {
212 // HTTP patterns with default port. 223 // HTTP patterns with default port.
213 EXPECT_TRUE(Pattern("http://www.example.com:80").IsValid()); 224 EXPECT_TRUE(Pattern("http://www.example.com:80").IsValid());
214 EXPECT_STREQ("http://www.example.com:80", 225 EXPECT_STREQ("http://www.example.com:80",
215 Pattern("http://www.example.com:80").ToString().c_str()); 226 Pattern("http://www.example.com:80").ToString().c_str());
216 // HTTP patterns with none default port. 227 // HTTP patterns with none default port.
217 EXPECT_TRUE(Pattern("http://www.example.com:81").IsValid()); 228 EXPECT_TRUE(Pattern("http://www.example.com:81").IsValid());
218 EXPECT_STREQ("http://www.example.com:81", 229 EXPECT_STREQ("http://www.example.com:81",
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // file:/// normalization. 668 // file:/// normalization.
658 EXPECT_STREQ("file:///tmp/test.html", 669 EXPECT_STREQ("file:///tmp/test.html",
659 Pattern("file:///tmp/bar/../test.html").ToString().c_str()); 670 Pattern("file:///tmp/bar/../test.html").ToString().c_str());
660 671
661 // Invalid patterns. 672 // Invalid patterns.
662 EXPECT_STREQ("", Pattern("*example.com").ToString().c_str()); 673 EXPECT_STREQ("", Pattern("*example.com").ToString().c_str());
663 EXPECT_STREQ("", Pattern("example.*").ToString().c_str()); 674 EXPECT_STREQ("", Pattern("example.*").ToString().c_str());
664 EXPECT_STREQ("", Pattern("*\xC4\x87ira.com").ToString().c_str()); 675 EXPECT_STREQ("", Pattern("*\xC4\x87ira.com").ToString().c_str());
665 EXPECT_STREQ("", Pattern("\xC4\x87ira.*").ToString().c_str()); 676 EXPECT_STREQ("", Pattern("\xC4\x87ira.*").ToString().c_str());
666 } 677 }
OLDNEW
« chrome/common/content_settings_pattern.cc ('K') | « chrome/common/content_settings_pattern.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698