Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_utils_unittest.cc
blobd5eeecac3056cb147b130975715f7d3ba623c1a0
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/content_settings/content_settings_utils.h"
7 #include <string>
9 #include "testing/gtest/include/gtest/gtest.h"
11 TEST(ContentSettingsUtilsTest, ParsePatternString) {
12 content_settings::PatternPair pattern_pair;
14 pattern_pair = content_settings::ParsePatternString(std::string());
15 EXPECT_FALSE(pattern_pair.first.IsValid());
16 EXPECT_FALSE(pattern_pair.second.IsValid());
18 pattern_pair = content_settings::ParsePatternString(",");
19 EXPECT_FALSE(pattern_pair.first.IsValid());
20 EXPECT_FALSE(pattern_pair.second.IsValid());
22 pattern_pair = content_settings::ParsePatternString("http://www.foo.com");
23 EXPECT_TRUE(pattern_pair.first.IsValid());
24 EXPECT_EQ(pattern_pair.second, ContentSettingsPattern::Wildcard());
26 // This inconsistency is to recover from some broken code.
27 pattern_pair = content_settings::ParsePatternString("http://www.foo.com,");
28 EXPECT_TRUE(pattern_pair.first.IsValid());
29 EXPECT_FALSE(pattern_pair.second.IsValid());
31 pattern_pair = content_settings::ParsePatternString(
32 "http://www.foo.com,http://www.bar.com");
33 EXPECT_TRUE(pattern_pair.first.IsValid());
34 EXPECT_TRUE(pattern_pair.second.IsValid());
36 pattern_pair = content_settings::ParsePatternString(
37 "http://www.foo.com,http://www.bar.com,");
38 EXPECT_FALSE(pattern_pair.first.IsValid());
39 EXPECT_FALSE(pattern_pair.second.IsValid());
41 pattern_pair = content_settings::ParsePatternString(
42 "http://www.foo.com,http://www.bar.com,http://www.error.com");
43 EXPECT_FALSE(pattern_pair.first.IsValid());
44 EXPECT_FALSE(pattern_pair.second.IsValid());