OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/content_settings_dialog_controller.h" | 5 #import "chrome/browser/cocoa/content_settings_dialog_controller.h" |
6 | 6 |
| 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" |
7 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
8 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
9 #include "chrome/browser/cocoa/browser_test_helper.h" | 11 #include "chrome/browser/cocoa/browser_test_helper.h" |
10 #include "chrome/browser/cocoa/cocoa_test_helper.h" | 12 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
11 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 13 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
12 #include "chrome/browser/host_content_settings_map.h" | 14 #include "chrome/browser/host_content_settings_map.h" |
13 #include "chrome/browser/notifications/desktop_notification_service.h" | 15 #include "chrome/browser/notifications/desktop_notification_service.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/common/chrome_switches.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
18 | 21 |
19 namespace { | 22 namespace { |
20 | 23 |
21 class ContentSettingsDialogControllerTest : public CocoaTest { | 24 class ContentSettingsDialogControllerTest : public CocoaTest { |
22 public: | 25 public: |
23 virtual void SetUp() { | 26 virtual void SetUp() { |
24 CocoaTest::SetUp(); | 27 CocoaTest::SetUp(); |
25 TestingProfile* profile = browser_helper_.profile(); | 28 TestingProfile* profile = browser_helper_.profile(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 TEST_F(ContentSettingsDialogControllerTest, PluginsSetting) { | 160 TEST_F(ContentSettingsDialogControllerTest, PluginsSetting) { |
158 // Change setting, check dialog property. | 161 // Change setting, check dialog property. |
159 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 162 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
160 CONTENT_SETTING_ALLOW); | 163 CONTENT_SETTING_ALLOW); |
161 EXPECT_EQ(kPluginsAllowIndex, [controller_ pluginsEnabledIndex]); | 164 EXPECT_EQ(kPluginsAllowIndex, [controller_ pluginsEnabledIndex]); |
162 | 165 |
163 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 166 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
164 CONTENT_SETTING_BLOCK); | 167 CONTENT_SETTING_BLOCK); |
165 EXPECT_EQ(kPluginsBlockIndex, [controller_ pluginsEnabledIndex]); | 168 EXPECT_EQ(kPluginsBlockIndex, [controller_ pluginsEnabledIndex]); |
166 | 169 |
167 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, | 170 { |
168 CONTENT_SETTING_ASK); | 171 // Click-to-play needs to be enabled to set the content setting to ASK. |
169 EXPECT_EQ(kPluginsAskIndex, [controller_ pluginsEnabledIndex]); | 172 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 173 AutoReset<CommandLine> auto_reset(cmd, *cmd); |
| 174 cmd->AppendSwitch(switches::kEnableClickToPlay); |
| 175 |
| 176 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 177 CONTENT_SETTING_ASK); |
| 178 EXPECT_EQ(kPluginsAskIndex, [controller_ pluginsEnabledIndex]); |
| 179 } |
170 | 180 |
171 // Change dialog property, check setting. | 181 // Change dialog property, check setting. |
172 NSInteger setting; | 182 NSInteger setting; |
173 [controller_ setPluginsEnabledIndex:kPluginsAllowIndex]; | 183 [controller_ setPluginsEnabledIndex:kPluginsAllowIndex]; |
174 setting = | 184 setting = |
175 settingsMap_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); | 185 settingsMap_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); |
176 EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); | 186 EXPECT_EQ(CONTENT_SETTING_ALLOW, setting); |
177 | 187 |
178 [controller_ setPluginsEnabledIndex:kPluginsBlockIndex]; | 188 [controller_ setPluginsEnabledIndex:kPluginsBlockIndex]; |
179 setting = | 189 setting = |
180 settingsMap_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); | 190 settingsMap_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); |
181 EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); | 191 EXPECT_EQ(CONTENT_SETTING_BLOCK, setting); |
182 | 192 |
183 [controller_ setPluginsEnabledIndex:kPluginsAskIndex]; | 193 { |
184 setting = | 194 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
185 settingsMap_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); | 195 AutoReset<CommandLine> auto_reset(cmd, *cmd); |
186 EXPECT_EQ(CONTENT_SETTING_ASK, setting); | 196 cmd->AppendSwitch(switches::kEnableClickToPlay); |
| 197 |
| 198 [controller_ setPluginsEnabledIndex:kPluginsAskIndex]; |
| 199 setting = |
| 200 settingsMap_->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); |
| 201 EXPECT_EQ(CONTENT_SETTING_ASK, setting); |
| 202 } |
187 } | 203 } |
188 | 204 |
189 TEST_F(ContentSettingsDialogControllerTest, PopupsSetting) { | 205 TEST_F(ContentSettingsDialogControllerTest, PopupsSetting) { |
190 // Change setting, check dialog property. | 206 // Change setting, check dialog property. |
191 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, | 207 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, |
192 CONTENT_SETTING_ALLOW); | 208 CONTENT_SETTING_ALLOW); |
193 EXPECT_EQ([controller_ popupsEnabledIndex], kContentSettingsEnabledIndex); | 209 EXPECT_EQ([controller_ popupsEnabledIndex], kContentSettingsEnabledIndex); |
194 | 210 |
195 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, | 211 settingsMap_->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, |
196 CONTENT_SETTING_BLOCK); | 212 CONTENT_SETTING_BLOCK); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 EXPECT_EQ(setting, CONTENT_SETTING_ASK); | 280 EXPECT_EQ(setting, CONTENT_SETTING_ASK); |
265 | 281 |
266 [controller_ setNotificationsSettingIndex:kNotificationsDisabledIndex]; | 282 [controller_ setNotificationsSettingIndex:kNotificationsDisabledIndex]; |
267 setting = | 283 setting = |
268 notificationsService_->GetDefaultContentSetting(); | 284 notificationsService_->GetDefaultContentSetting(); |
269 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); | 285 EXPECT_EQ(setting, CONTENT_SETTING_BLOCK); |
270 } | 286 } |
271 | 287 |
272 } // namespace | 288 } // namespace |
273 | 289 |
OLD | NEW |