Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_provider_unittest.cc
blobb5933baeaabeb3b9a687528a3ec2c5a07dd861c8
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 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
27 EXPECT_EQ(CONTENT_SETTING_BLOCK,
28 GetContentSetting(&mock_provider, url, url,
29 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
30 false));
31 scoped_ptr<base::Value> value_ptr(
32 GetContentSettingValue(&mock_provider, url, url,
33 CONTENT_SETTINGS_TYPE_PLUGINS,
34 "java_plugin", false));
35 int int_value = -1;
36 value_ptr->GetAsInteger(&int_value);
37 EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(int_value));
39 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
40 GetContentSetting(&mock_provider, url, url,
41 CONTENT_SETTINGS_TYPE_PLUGINS, "flash_plugin",
42 false));
43 EXPECT_EQ(NULL,
44 GetContentSettingValue(&mock_provider, url, url,
45 CONTENT_SETTINGS_TYPE_PLUGINS,
46 "flash_plugin", false));
47 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
48 GetContentSetting(&mock_provider,
49 url,
50 url,
51 CONTENT_SETTINGS_TYPE_GEOLOCATION,
52 std::string(),
53 false));
54 EXPECT_EQ(NULL,
55 GetContentSettingValue(&mock_provider,
56 url,
57 url,
58 CONTENT_SETTINGS_TYPE_GEOLOCATION,
59 std::string(),
60 false));
62 bool owned = mock_provider.SetWebsiteSetting(
63 pattern,
64 pattern,
65 CONTENT_SETTINGS_TYPE_PLUGINS,
66 "java_plugin",
67 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
68 EXPECT_TRUE(owned);
69 EXPECT_EQ(CONTENT_SETTING_ALLOW,
70 GetContentSetting(&mock_provider, url, url,
71 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
72 false));
74 mock_provider.set_read_only(true);
75 scoped_ptr<base::Value> value(
76 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
77 owned = mock_provider.SetWebsiteSetting(
78 pattern,
79 pattern,
80 CONTENT_SETTINGS_TYPE_PLUGINS,
81 "java_plugin",
82 value.get());
83 EXPECT_FALSE(owned);
84 EXPECT_EQ(CONTENT_SETTING_ALLOW,
85 GetContentSetting(&mock_provider, url, url,
86 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
87 false));
89 EXPECT_TRUE(mock_provider.read_only());
91 mock_provider.set_read_only(false);
92 owned = mock_provider.SetWebsiteSetting(
93 pattern,
94 pattern,
95 CONTENT_SETTINGS_TYPE_PLUGINS,
96 "java_plugin",
97 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
98 EXPECT_TRUE(owned);
99 EXPECT_EQ(CONTENT_SETTING_BLOCK,
100 GetContentSetting(&mock_provider, url, url,
101 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
102 false));
105 } // namespace content_settings