| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/cocoa/website_settings/website_settings_bubble_contro
ller.h" | 5 #import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_contro
ller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 // Indices of the menu items in the permission menu. | 57 // Indices of the menu items in the permission menu. |
| 58 enum PermissionMenuIndices { | 58 enum PermissionMenuIndices { |
| 59 kMenuIndexContentSettingAllow = 0, | 59 kMenuIndexContentSettingAllow = 0, |
| 60 kMenuIndexContentSettingBlock, | 60 kMenuIndexContentSettingBlock, |
| 61 kMenuIndexContentSettingDefault | 61 kMenuIndexContentSettingDefault |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 const ContentSettingsType kTestPermissionTypes[] = { | 64 const ContentSettingsType kTestPermissionTypes[] = { |
| 65 // NOTE: FULLSCREEN does not support "Always block", so it must appear as | |
| 66 // one of the first three permissions. | |
| 67 CONTENT_SETTINGS_TYPE_FULLSCREEN, | |
| 68 CONTENT_SETTINGS_TYPE_IMAGES, | 65 CONTENT_SETTINGS_TYPE_IMAGES, |
| 69 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 66 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 70 CONTENT_SETTINGS_TYPE_PLUGINS, | 67 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 71 CONTENT_SETTINGS_TYPE_POPUPS, | 68 CONTENT_SETTINGS_TYPE_POPUPS, |
| 72 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 69 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 73 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 70 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 74 CONTENT_SETTINGS_TYPE_MOUSELOCK, | |
| 75 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC | 71 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC |
| 76 }; | 72 }; |
| 77 | 73 |
| 78 const ContentSetting kTestSettings[] = { | 74 const ContentSetting kTestSettings[] = { |
| 79 CONTENT_SETTING_DEFAULT, | 75 CONTENT_SETTING_DEFAULT, |
| 80 CONTENT_SETTING_DEFAULT, | 76 CONTENT_SETTING_DEFAULT, |
| 81 CONTENT_SETTING_DEFAULT, | |
| 82 CONTENT_SETTING_ALLOW, | 77 CONTENT_SETTING_ALLOW, |
| 83 CONTENT_SETTING_BLOCK, | 78 CONTENT_SETTING_BLOCK, |
| 84 CONTENT_SETTING_ALLOW, | 79 CONTENT_SETTING_ALLOW, |
| 85 CONTENT_SETTING_BLOCK, | 80 CONTENT_SETTING_BLOCK, |
| 86 CONTENT_SETTING_ALLOW, | |
| 87 CONTENT_SETTING_BLOCK | 81 CONTENT_SETTING_BLOCK |
| 88 }; | 82 }; |
| 89 | 83 |
| 90 const ContentSetting kTestDefaultSettings[] = { | 84 const ContentSetting kTestDefaultSettings[] = { |
| 91 CONTENT_SETTING_ALLOW, | |
| 92 CONTENT_SETTING_BLOCK, | 85 CONTENT_SETTING_BLOCK, |
| 93 CONTENT_SETTING_ASK | 86 CONTENT_SETTING_ASK |
| 94 }; | 87 }; |
| 95 | 88 |
| 96 const content_settings::SettingSource kTestSettingSources[] = { | 89 const content_settings::SettingSource kTestSettingSources[] = { |
| 97 content_settings::SETTING_SOURCE_USER, | 90 content_settings::SETTING_SOURCE_USER, |
| 98 content_settings::SETTING_SOURCE_USER, | 91 content_settings::SETTING_SOURCE_USER, |
| 99 content_settings::SETTING_SOURCE_USER, | 92 content_settings::SETTING_SOURCE_USER, |
| 100 content_settings::SETTING_SOURCE_USER, | 93 content_settings::SETTING_SOURCE_USER, |
| 101 content_settings::SETTING_SOURCE_USER, | |
| 102 content_settings::SETTING_SOURCE_POLICY, | 94 content_settings::SETTING_SOURCE_POLICY, |
| 103 content_settings::SETTING_SOURCE_POLICY, | 95 content_settings::SETTING_SOURCE_POLICY, |
| 104 content_settings::SETTING_SOURCE_EXTENSION, | |
| 105 content_settings::SETTING_SOURCE_EXTENSION | 96 content_settings::SETTING_SOURCE_EXTENSION |
| 106 }; | 97 }; |
| 107 | 98 |
| 108 class WebsiteSettingsBubbleControllerTest : public CocoaTest { | 99 class WebsiteSettingsBubbleControllerTest : public CocoaTest { |
| 109 public: | 100 public: |
| 110 WebsiteSettingsBubbleControllerTest() { | 101 WebsiteSettingsBubbleControllerTest() { |
| 111 controller_ = nil; | 102 controller_ = nil; |
| 112 } | 103 } |
| 113 | 104 |
| 114 void TearDown() override { | 105 void TearDown() override { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 if ([view isKindOfClass:[NSPopUpButton class]]) { | 272 if ([view isKindOfClass:[NSPopUpButton class]]) { |
| 282 NSPopUpButton* button = static_cast<NSPopUpButton*>(view); | 273 NSPopUpButton* button = static_cast<NSPopUpButton*>(view); |
| 283 [labels addObject:[[button selectedCell] title]]; | 274 [labels addObject:[[button selectedCell] title]]; |
| 284 | 275 |
| 285 if (![button isEnabled]) | 276 if (![button isEnabled]) |
| 286 ++disabled_count; | 277 ++disabled_count; |
| 287 } | 278 } |
| 288 } | 279 } |
| 289 EXPECT_EQ(arraysize(kTestPermissionTypes), [labels count]); | 280 EXPECT_EQ(arraysize(kTestPermissionTypes), [labels count]); |
| 290 | 281 |
| 291 // 4 of the buttons should be disabled -- the ones that have a setting source | 282 // 3 of the buttons should be disabled -- the ones that have a setting source |
| 292 // of SETTING_SOURCE_POLICY or SETTING_SOURCE_EXTENSION. | 283 // of SETTING_SOURCE_POLICY or SETTING_SOURCE_EXTENSION. |
| 293 EXPECT_EQ(4, disabled_count); | 284 EXPECT_EQ(3, disabled_count); |
| 294 } | 285 } |
| 295 | 286 |
| 296 TEST_F(WebsiteSettingsBubbleControllerTest, WindowWidth) { | 287 TEST_F(WebsiteSettingsBubbleControllerTest, WindowWidth) { |
| 297 const CGFloat kBigEnoughBubbleWidth = 310; | 288 const CGFloat kBigEnoughBubbleWidth = 310; |
| 298 // Creating a window that should fit everything. | 289 // Creating a window that should fit everything. |
| 299 CreateBubbleWithWidth(kBigEnoughBubbleWidth); | 290 CreateBubbleWithWidth(kBigEnoughBubbleWidth); |
| 300 SetTestPermissions(); | 291 SetTestPermissions(); |
| 301 | 292 |
| 302 CGFloat window_width = NSWidth([[controller_ window] frame]); | 293 CGFloat window_width = NSWidth([[controller_ window] frame]); |
| 303 | 294 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 324 } | 315 } |
| 325 if ([view isKindOfClass:[NSPopUpButton class]]) { | 316 if ([view isKindOfClass:[NSPopUpButton class]]) { |
| 326 NSPopUpButton* button = static_cast<NSPopUpButton*>(view); | 317 NSPopUpButton* button = static_cast<NSPopUpButton*>(view); |
| 327 EXPECT_LT(NSMaxX([button frame]), window_width); | 318 EXPECT_LT(NSMaxX([button frame]), window_width); |
| 328 } | 319 } |
| 329 } | 320 } |
| 330 } | 321 } |
| 331 } | 322 } |
| 332 | 323 |
| 333 } // namespace | 324 } // namespace |
| OLD | NEW |