Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: chrome/browser/ui/cocoa/website_settings_bubble_controller_unittest.mm

Issue 11443018: Revert 171259 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/website_settings_bubble_controller_unittest.mm
===================================================================
--- chrome/browser/ui/cocoa/website_settings_bubble_controller_unittest.mm (revision 171274)
+++ chrome/browser/ui/cocoa/website_settings_bubble_controller_unittest.mm (working copy)
@@ -61,24 +61,6 @@
}
@end
-@interface WebsiteSettingsBubbleControllerForTesting
- : WebsiteSettingsBubbleController {
- @private
- CGFloat defaultWindowWidth_;
-}
-@end
-
-@implementation WebsiteSettingsBubbleControllerForTesting
-- (void)setDefaultWindowWidth:(CGFloat)width {
- defaultWindowWidth_ = width;
-}
-- (CGFloat)defaultWindowWidth {
- // If |defaultWindowWidth_| is 0, use the superclass implementation.
- return defaultWindowWidth_ ?
- defaultWindowWidth_ : [super defaultWindowWidth];
-}
-@end
-
namespace {
// Indices of the menu items in the permission menu.
@@ -88,50 +70,6 @@
kMenuIndexContentSettingDefault
};
-const ContentSettingsType kTestPermissionTypes[] = {
- // NOTE: FULLSCREEN does not support "Always block", so it must appear as
- // one of the first three permissions.
- CONTENT_SETTINGS_TYPE_FULLSCREEN,
- CONTENT_SETTINGS_TYPE_IMAGES,
- CONTENT_SETTINGS_TYPE_JAVASCRIPT,
- CONTENT_SETTINGS_TYPE_PLUGINS,
- CONTENT_SETTINGS_TYPE_POPUPS,
- CONTENT_SETTINGS_TYPE_GEOLOCATION,
- CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
- CONTENT_SETTINGS_TYPE_MOUSELOCK,
- CONTENT_SETTINGS_TYPE_MEDIASTREAM,
-};
-
-const ContentSetting kTestSettings[] = {
- CONTENT_SETTING_DEFAULT,
- CONTENT_SETTING_DEFAULT,
- CONTENT_SETTING_DEFAULT,
- CONTENT_SETTING_ALLOW,
- CONTENT_SETTING_BLOCK,
- CONTENT_SETTING_ALLOW,
- CONTENT_SETTING_BLOCK,
- CONTENT_SETTING_ALLOW,
- CONTENT_SETTING_BLOCK,
-};
-
-const ContentSetting kTestDefaultSettings[] = {
- CONTENT_SETTING_ALLOW,
- CONTENT_SETTING_BLOCK,
- CONTENT_SETTING_ASK
-};
-
-const content_settings::SettingSource kTestSettingSources[] = {
- content_settings::SETTING_SOURCE_USER,
- content_settings::SETTING_SOURCE_USER,
- content_settings::SETTING_SOURCE_USER,
- content_settings::SETTING_SOURCE_USER,
- content_settings::SETTING_SOURCE_USER,
- content_settings::SETTING_SOURCE_POLICY,
- content_settings::SETTING_SOURCE_POLICY,
- content_settings::SETTING_SOURCE_EXTENSION,
- content_settings::SETTING_SOURCE_EXTENSION,
-};
-
class WebsiteSettingsBubbleControllerTest : public CocoaTest {
public:
WebsiteSettingsBubbleControllerTest() {
@@ -151,26 +89,20 @@
TEXT_NOT_EQUAL
};
- // Creates a new website settings bubble, with the given default width.
- // If |default_width| is 0, the *default* default width will be used.
- void CreateBubbleWithWidth(CGFloat default_width) {
+ void CreateBubble() {
bridge_ = new WebsiteSettingsUIBridge();
// The controller cleans up after itself when the window closes.
- controller_ = [WebsiteSettingsBubbleControllerForTesting alloc];
- [controller_ setDefaultWindowWidth:default_width];
- [controller_ initWithParentWindow:test_window()
- websiteSettingsUIBridge:bridge_
- tabContents:nil
- isInternalPage:NO];
+ controller_ =
+ [[WebsiteSettingsBubbleController alloc]
+ initWithParentWindow:test_window()
+ websiteSettingsUIBridge:bridge_
+ tabContents:nil
+ isInternalPage:NO];
window_ = [controller_ window];
[controller_ showWindow:nil];
}
- void CreateBubble() {
- CreateBubbleWithWidth(0.0);
- }
-
// Return a pointer to the first NSTextField found that either matches, or
// doesn't match, the given text.
NSTextField* FindTextField(MatchType match_type, NSString* text) {
@@ -205,26 +137,7 @@
return views;
}
- // Sets up the dialog with some test permission settings.
- void SetTestPermissions() {
- // Create a list of 5 different permissions, corresponding to all the
- // possible settings:
- // - [allow, block, ask] by default
- // - [block, allow] * [by user, by policy, by extension]
- PermissionInfoList list;
- WebsiteSettingsUI::PermissionInfo info;
- for (size_t i = 0; i < arraysize(kTestPermissionTypes); ++i) {
- info.type = kTestPermissionTypes[i];
- info.setting = kTestSettings[i];
- if (info.setting == CONTENT_SETTING_DEFAULT)
- info.default_setting = kTestDefaultSettings[i];
- info.source = kTestSettingSources[i];
- list.push_back(info);
- }
- bridge_->SetPermissionInfo(list);
- }
-
- WebsiteSettingsBubbleControllerForTesting* controller_; // Weak, owns self.
+ WebsiteSettingsBubbleController* controller_; // Weak, owns self.
NSWindow* window_; // Weak, owned by controller.
};
@@ -325,8 +238,67 @@
TEST_F(WebsiteSettingsBubbleControllerTest, SetPermissionInfo) {
CreateBubble();
- SetTestPermissions();
+ const ContentSettingsType kTestPermissionTypes[] = {
+ // NOTE: FULLSCREEN does not support "Always block", so it must appear as
+ // one of the first three permissions.
+ CONTENT_SETTINGS_TYPE_FULLSCREEN,
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ CONTENT_SETTINGS_TYPE_MOUSELOCK,
+ CONTENT_SETTINGS_TYPE_MEDIASTREAM,
+ };
+
+ const ContentSetting kTestSettings[] = {
+ CONTENT_SETTING_DEFAULT,
+ CONTENT_SETTING_DEFAULT,
+ CONTENT_SETTING_DEFAULT,
+ CONTENT_SETTING_ALLOW,
+ CONTENT_SETTING_BLOCK,
+ CONTENT_SETTING_ALLOW,
+ CONTENT_SETTING_BLOCK,
+ CONTENT_SETTING_ALLOW,
+ CONTENT_SETTING_BLOCK,
+ };
+
+ const ContentSetting kTestDefaultSettings[] = {
+ CONTENT_SETTING_ALLOW,
+ CONTENT_SETTING_BLOCK,
+ CONTENT_SETTING_ASK
+ };
+
+ const content_settings::SettingSource kTestSettingSources[] = {
+ content_settings::SETTING_SOURCE_USER,
+ content_settings::SETTING_SOURCE_USER,
+ content_settings::SETTING_SOURCE_USER,
+ content_settings::SETTING_SOURCE_USER,
+ content_settings::SETTING_SOURCE_USER,
+ content_settings::SETTING_SOURCE_POLICY,
+ content_settings::SETTING_SOURCE_POLICY,
+ content_settings::SETTING_SOURCE_EXTENSION,
+ content_settings::SETTING_SOURCE_EXTENSION,
+ };
+
+ // Create a list of 5 different permissions, corresponding to all the
+ // possible settings:
+ // - [allow, block, ask] by default
+ // - [block, allow] * [by user, by policy, by extension]
+ PermissionInfoList list;
+ WebsiteSettingsUI::PermissionInfo info;
+ for (size_t i = 0; i < arraysize(kTestPermissionTypes); ++i) {
+ info.type = kTestPermissionTypes[i];
+ info.setting = kTestSettings[i];
+ if (info.setting == CONTENT_SETTING_DEFAULT)
+ info.default_setting = kTestDefaultSettings[i];
+ info.source = kTestSettingSources[i];
+ list.push_back(info);
+ }
+ bridge_->SetPermissionInfo(list);
+
// There should be three subviews per permission (an icon, a label and a
// select box), plus a text label for the Permission section.
NSArray* subviews = [[controller_ permissionsView] subviews];
@@ -377,24 +349,4 @@
EXPECT_EQ(1, [tabView indexOfTabViewItem:[tabView selectedTabViewItem]]);
}
-TEST_F(WebsiteSettingsBubbleControllerTest, WindowWidth) {
- // Try creating a window that is obviously too small.
- CreateBubbleWithWidth(30.0);
- SetTestPermissions();
-
- CGFloat window_width = NSWidth([[controller_ window] frame]);
-
- // Check the window was made bigger to fit the content.
- EXPECT_LT(30.0, window_width);
-
- // Check that the window is wider than the right edge of all the permission
- // popup buttons.
- for (NSView* view in [[controller_ permissionsView] subviews]) {
- if ([view isKindOfClass:[NSPopUpButton class]]) {
- NSPopUpButton* button = static_cast<NSPopUpButton*>(view);
- EXPECT_LT(NSMaxX([button frame]), window_width);
- }
- }
-}
-
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698