Chromium Code Reviews| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/content_settings/content_settings_mock_provider.h" | 8 #include "chrome/browser/content_settings/content_settings_mock_provider.h" |
| 9 #include "chrome/browser/content_settings/content_settings_utils.h" | 9 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 | 11 |
| 12 namespace content_settings { | 12 namespace content_settings { |
| 13 | 13 |
| 14 TEST(ContentSettingsProviderTest, Mock) { | 14 TEST(ContentSettingsProviderTest, Mock) { |
|
Bernhard Bauer
2011/11/11 14:00:40
Yak shave: This should probably be a ContentSettin
markusheintz_
2011/11/14 11:15:10
My new mantra is: Keep the CL as small as possible
| |
| 15 ContentSettingsPattern pattern = | 15 ContentSettingsPattern pattern = |
| 16 ContentSettingsPattern::FromString("[*.]youtube.com"); | 16 ContentSettingsPattern::FromString("[*.]youtube.com"); |
| 17 GURL url("http://www.youtube.com"); | 17 GURL url("http://www.youtube.com"); |
| 18 | 18 |
| 19 MockProvider mock_provider( | 19 MockProvider mock_provider( |
| 20 pattern, | 20 pattern, |
| 21 pattern, | 21 pattern, |
| 22 CONTENT_SETTINGS_TYPE_PLUGINS, | 22 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 23 "java_plugin", | 23 "java_plugin", |
| 24 CONTENT_SETTING_BLOCK, | 24 CONTENT_SETTING_BLOCK, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 46 CONTENT_SETTINGS_TYPE_PLUGINS, | 46 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 47 "flash_plugin", false)); | 47 "flash_plugin", false)); |
| 48 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 48 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 49 GetContentSetting(&mock_provider, url, url, | 49 GetContentSetting(&mock_provider, url, url, |
| 50 CONTENT_SETTINGS_TYPE_GEOLOCATION, "", false)); | 50 CONTENT_SETTINGS_TYPE_GEOLOCATION, "", false)); |
| 51 EXPECT_EQ(NULL, | 51 EXPECT_EQ(NULL, |
| 52 GetContentSettingValue(&mock_provider, url, url, | 52 GetContentSettingValue(&mock_provider, url, url, |
| 53 CONTENT_SETTINGS_TYPE_GEOLOCATION, "", | 53 CONTENT_SETTINGS_TYPE_GEOLOCATION, "", |
| 54 false)); | 54 false)); |
| 55 | 55 |
| 56 mock_provider.SetContentSetting( | 56 scoped_ptr<base::Value> value; |
| 57 value.reset(Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); | |
| 58 mock_provider.SetWebsiteSetting( | |
| 57 pattern, | 59 pattern, |
| 58 pattern, | 60 pattern, |
| 59 CONTENT_SETTINGS_TYPE_PLUGINS, | 61 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 60 "java_plugin", | 62 "java_plugin", |
| 61 CONTENT_SETTING_ALLOW); | 63 value.get()); |
| 62 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 64 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 63 GetContentSetting(&mock_provider, url, url, | 65 GetContentSetting(&mock_provider, url, url, |
| 64 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin", | 66 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin", |
| 65 false)); | 67 false)); |
| 66 | 68 |
| 69 value.reset(Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); | |
| 67 mock_provider.set_read_only(true); | 70 mock_provider.set_read_only(true); |
| 68 mock_provider.SetContentSetting( | 71 mock_provider.SetWebsiteSetting( |
| 69 pattern, | 72 pattern, |
| 70 pattern, | 73 pattern, |
| 71 CONTENT_SETTINGS_TYPE_PLUGINS, | 74 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 72 "java_plugin", | 75 "java_plugin", |
| 73 CONTENT_SETTING_BLOCK); | 76 value.get()); |
| 74 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 77 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 75 GetContentSetting(&mock_provider, url, url, | 78 GetContentSetting(&mock_provider, url, url, |
| 76 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin", | 79 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin", |
| 77 false)); | 80 false)); |
| 78 | 81 |
| 79 EXPECT_TRUE(mock_provider.read_only()); | 82 EXPECT_TRUE(mock_provider.read_only()); |
| 80 | 83 |
| 81 mock_provider.set_read_only(false); | 84 mock_provider.set_read_only(false); |
| 82 mock_provider.SetContentSetting( | 85 mock_provider.SetWebsiteSetting( |
| 83 pattern, | 86 pattern, |
| 84 pattern, | 87 pattern, |
| 85 CONTENT_SETTINGS_TYPE_PLUGINS, | 88 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 86 "java_plugin", | 89 "java_plugin", |
| 87 CONTENT_SETTING_BLOCK); | 90 value.get()); |
| 88 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 91 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 89 GetContentSetting(&mock_provider, url, url, | 92 GetContentSetting(&mock_provider, url, url, |
| 90 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin", | 93 CONTENT_SETTINGS_TYPE_PLUGINS, "java_plugin", |
| 91 false)); | 94 false)); |
| 92 } | 95 } |
| 93 | 96 |
| 94 } // namespace content_settings | 97 } // namespace content_settings |
| OLD | NEW |