blob: f89b45b42f9f4ad3eda913c973a263da655d0eca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/content_settings/core/browser/content_settings_utils.h"
#include <string>
#include "components/content_settings/core/test/content_settings_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(ContentSettingsUtilsTest, ParsePatternString) {
content_settings::PatternPair pattern_pair;
pattern_pair = content_settings::ParsePatternString(std::string());
EXPECT_FALSE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString(",");
EXPECT_FALSE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString("http://www.foo.com");
EXPECT_TRUE(pattern_pair.first.IsValid());
EXPECT_EQ(pattern_pair.second, ContentSettingsPattern::Wildcard());
// This inconsistency is to recover from some broken code.
pattern_pair = content_settings::ParsePatternString("http://www.foo.com,");
EXPECT_TRUE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString(
"http://www.foo.com,http://www.bar.com");
EXPECT_TRUE(pattern_pair.first.IsValid());
EXPECT_TRUE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString(
"http://www.foo.com,http://www.bar.com,");
EXPECT_FALSE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
pattern_pair = content_settings::ParsePatternString(
"http://www.foo.com,http://www.bar.com,http://www.error.com");
EXPECT_FALSE(pattern_pair.first.IsValid());
EXPECT_FALSE(pattern_pair.second.IsValid());
}
|