Introduce ProfilerMetricsProvider
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_provider_unittest.cc
blobefd82e59b6165075f8bff6efea4240933801b660
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 "testing/gtest/include/gtest/gtest.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/content_settings/content_settings_mock_provider.h"
9 #include "chrome/browser/content_settings/content_settings_utils.h"
10 #include "url/gurl.h"
12 namespace content_settings {
14 TEST(ContentSettingsProviderTest, Mock) {
15 ContentSettingsPattern pattern =
16 ContentSettingsPattern::FromString("[*.]youtube.com");
17 GURL url("http://www.youtube.com");
19 MockProvider mock_provider(false);
20 mock_provider.SetWebsiteSetting(
21 pattern,
22 pattern,
23 CONTENT_SETTINGS_TYPE_PLUGINS,
24 "java_plugin",
25 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
28 EXPECT_EQ(CONTENT_SETTING_BLOCK,
29 GetContentSetting(&mock_provider, url, url,
30 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
31 false));
32 scoped_ptr<base::Value> value_ptr(
33 GetContentSettingValue(&mock_provider, url, url,
34 CONTENT_SETTINGS_TYPE_PLUGINS,
35 "java_plugin", false));
36 int int_value = -1;
37 value_ptr->GetAsInteger(&int_value);
38 EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(int_value));
40 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
41 GetContentSetting(&mock_provider, url, url,
42 CONTENT_SETTINGS_TYPE_PLUGINS, "flash_plugin",
43 false));
44 EXPECT_EQ(NULL,
45 GetContentSettingValue(&mock_provider, url, url,
46 CONTENT_SETTINGS_TYPE_PLUGINS,
47 "flash_plugin", false));
48 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
49 GetContentSetting(&mock_provider,
50 url,
51 url,
52 CONTENT_SETTINGS_TYPE_GEOLOCATION,
53 std::string(),
54 false));
55 EXPECT_EQ(NULL,
56 GetContentSettingValue(&mock_provider,
57 url,
58 url,
59 CONTENT_SETTINGS_TYPE_GEOLOCATION,
60 std::string(),
61 false));
63 bool owned = mock_provider.SetWebsiteSetting(
64 pattern,
65 pattern,
66 CONTENT_SETTINGS_TYPE_PLUGINS,
67 "java_plugin",
68 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW));
69 EXPECT_TRUE(owned);
70 EXPECT_EQ(CONTENT_SETTING_ALLOW,
71 GetContentSetting(&mock_provider, url, url,
72 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
73 false));
75 mock_provider.set_read_only(true);
76 scoped_ptr<base::Value> value(
77 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
78 owned = mock_provider.SetWebsiteSetting(
79 pattern,
80 pattern,
81 CONTENT_SETTINGS_TYPE_PLUGINS,
82 "java_plugin",
83 value.get());
84 EXPECT_FALSE(owned);
85 EXPECT_EQ(CONTENT_SETTING_ALLOW,
86 GetContentSetting(&mock_provider, url, url,
87 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
88 false));
90 EXPECT_TRUE(mock_provider.read_only());
92 mock_provider.set_read_only(false);
93 owned = mock_provider.SetWebsiteSetting(
94 pattern,
95 pattern,
96 CONTENT_SETTINGS_TYPE_PLUGINS,
97 "java_plugin",
98 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
99 EXPECT_TRUE(owned);
100 EXPECT_EQ(CONTENT_SETTING_BLOCK,
101 GetContentSetting(&mock_provider, url, url,
102 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
103 false));
106 } // namespace content_settings