OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "components/content_settings/core/browser/content_settings_utils.h" | 5 #include "components/content_settings/core/browser/content_settings_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "components/content_settings/core/test/content_settings_test_utils.h" | 9 #include "components/content_settings/core/test/content_settings_test_utils.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 pattern_pair = content_settings::ParsePatternString( | 37 pattern_pair = content_settings::ParsePatternString( |
38 "http://www.foo.com,http://www.bar.com,"); | 38 "http://www.foo.com,http://www.bar.com,"); |
39 EXPECT_FALSE(pattern_pair.first.IsValid()); | 39 EXPECT_FALSE(pattern_pair.first.IsValid()); |
40 EXPECT_FALSE(pattern_pair.second.IsValid()); | 40 EXPECT_FALSE(pattern_pair.second.IsValid()); |
41 | 41 |
42 pattern_pair = content_settings::ParsePatternString( | 42 pattern_pair = content_settings::ParsePatternString( |
43 "http://www.foo.com,http://www.bar.com,http://www.error.com"); | 43 "http://www.foo.com,http://www.bar.com,http://www.error.com"); |
44 EXPECT_FALSE(pattern_pair.first.IsValid()); | 44 EXPECT_FALSE(pattern_pair.first.IsValid()); |
45 EXPECT_FALSE(pattern_pair.second.IsValid()); | 45 EXPECT_FALSE(pattern_pair.second.IsValid()); |
46 } | 46 } |
47 | |
48 TEST(ContentSettingsUtilsTest, ContentSettingsStringMap) { | |
49 // Checking content_settings::ContentSettingToString() functionality. | |
Bernhard Bauer
2015/10/06 15:37:25
Nit: Remove this comment, the code tell you pretty
Deepak
2015/10/07 04:39:43
Done.
| |
50 EXPECT_EQ("default", | |
AKV
2015/10/06 16:01:38
If we define constant variable instead of hard cod
Deepak
2015/10/07 04:39:43
Done.
| |
51 content_settings::ContentSettingToString(CONTENT_SETTING_DEFAULT)); | |
52 EXPECT_EQ("allow", | |
53 content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW)); | |
54 EXPECT_EQ("block", | |
55 content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK)); | |
56 EXPECT_EQ("ask", | |
57 content_settings::ContentSettingToString(CONTENT_SETTING_ASK)); | |
58 EXPECT_EQ("session_only", content_settings::ContentSettingToString( | |
59 CONTENT_SETTING_SESSION_ONLY)); | |
60 EXPECT_EQ("detect_important_content", | |
AKV
2015/10/06 16:01:38
Can we add a test case, for failure case by passin
Deepak
2015/10/07 04:39:43
We can add negative test case for content_settings
Bernhard Bauer
2015/10/07 09:32:03
If we remove that DCHECK (see my other comment), w
| |
61 content_settings::ContentSettingToString( | |
62 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT)); | |
63 | |
64 // Checking content_settings::ContentSettingFromString() functionality. | |
65 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
AKV
2015/10/06 16:01:38
ditto
Deepak
2015/10/07 04:39:43
Done.
| |
66 content_settings::ContentSettingFromString("allow")); | |
67 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
68 content_settings::ContentSettingFromString("block")); | |
69 EXPECT_EQ(CONTENT_SETTING_ASK, | |
70 content_settings::ContentSettingFromString("ask")); | |
71 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, | |
72 content_settings::ContentSettingFromString("session_only")); | |
73 EXPECT_EQ( | |
74 CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, | |
75 content_settings::ContentSettingFromString("detect_important_content")); | |
76 } | |
OLD | NEW |