Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_provider_unittest.cc
blobe0857b3292a9ffa36983b3d45f4cf14fe4d5eab0
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 "googleurl/src/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 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<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, url, url,
50 CONTENT_SETTINGS_TYPE_GEOLOCATION, "", false));
51 EXPECT_EQ(NULL,
52 GetContentSettingValue(&mock_provider, url, url,
53 CONTENT_SETTINGS_TYPE_GEOLOCATION, "",
54 false));
56 bool owned = mock_provider.SetWebsiteSetting(
57 pattern,
58 pattern,
59 CONTENT_SETTINGS_TYPE_PLUGINS,
60 "java_plugin",
61 Value::CreateIntegerValue(CONTENT_SETTING_ALLOW));
62 EXPECT_TRUE(owned);
63 EXPECT_EQ(CONTENT_SETTING_ALLOW,
64 GetContentSetting(&mock_provider, url, url,
65 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
66 false));
68 mock_provider.set_read_only(true);
69 scoped_ptr<base::Value> value(
70 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
71 owned = mock_provider.SetWebsiteSetting(
72 pattern,
73 pattern,
74 CONTENT_SETTINGS_TYPE_PLUGINS,
75 "java_plugin",
76 value.get());
77 EXPECT_FALSE(owned);
78 EXPECT_EQ(CONTENT_SETTING_ALLOW,
79 GetContentSetting(&mock_provider, url, url,
80 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
81 false));
83 EXPECT_TRUE(mock_provider.read_only());
85 mock_provider.set_read_only(false);
86 owned = mock_provider.SetWebsiteSetting(
87 pattern,
88 pattern,
89 CONTENT_SETTINGS_TYPE_PLUGINS,
90 "java_plugin",
91 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK));
92 EXPECT_TRUE(owned);
93 EXPECT_EQ(CONTENT_SETTING_BLOCK,
94 GetContentSetting(&mock_provider, url, url,
95 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin",
96 false));
99 } // namespace content_settings