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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings_bubble_controller_unittest.mm

Issue 10831280: [Mac] Website settings: Add cookie info & permission icons, plus other visual fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests. Created 8 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" 8 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
9 #include "testing/gtest_mac.h" 9 #include "testing/gtest_mac.h"
10 10
11 @interface WebsiteSettingsBubbleController (ExposedForTesting) 11 @interface WebsiteSettingsBubbleController (ExposedForTesting)
12 - (NSView*)permissionsContentView; 12 - (NSView*)permissionsView;
13 - (NSImageView*)identityStatusIcon; 13 - (NSImageView*)identityStatusIcon;
14 - (NSTextField*)identityStatusDescriptionField; 14 - (NSTextField*)identityStatusDescriptionField;
15 - (NSImageView*)connectionStatusIcon; 15 - (NSImageView*)connectionStatusIcon;
16 - (NSTextField*)connectionStatusDescriptionField; 16 - (NSTextField*)connectionStatusDescriptionField;
17 - (NSTextField*)firstVisitDescriptionField; 17 - (NSTextField*)firstVisitDescriptionField;
18 @end 18 @end
19 19
20 @implementation WebsiteSettingsBubbleController (ExposedForTesting) 20 @implementation WebsiteSettingsBubbleController (ExposedForTesting)
21 - (NSView*)permissionsContentView { 21 - (NSView*)permissionsView {
22 return permissionsContentView_; 22 return permissionsView_;
23 } 23 }
24 24
25 - (NSImageView*)identityStatusIcon { 25 - (NSImageView*)identityStatusIcon {
26 return identityStatusIcon_; 26 return identityStatusIcon_;
27 } 27 }
28 28
29 - (NSTextField*)identityStatusDescriptionField { 29 - (NSTextField*)identityStatusDescriptionField {
30 return identityStatusDescriptionField_; 30 return identityStatusDescriptionField_;
31 } 31 }
32 32
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 PermissionInfoList list; 198 PermissionInfoList list;
199 WebsiteSettingsUI::PermissionInfo info; 199 WebsiteSettingsUI::PermissionInfo info;
200 info.setting = CONTENT_SETTING_ALLOW; 200 info.setting = CONTENT_SETTING_ALLOW;
201 info.default_setting = CONTENT_SETTING_ALLOW; 201 info.default_setting = CONTENT_SETTING_ALLOW;
202 for (size_t i = 0; i < arraysize(kTestPermissionTypes); ++i) { 202 for (size_t i = 0; i < arraysize(kTestPermissionTypes); ++i) {
203 info.type = kTestPermissionTypes[i]; 203 info.type = kTestPermissionTypes[i];
204 list.push_back(info); 204 list.push_back(info);
205 } 205 }
206 bridge_->SetPermissionInfo(list); 206 bridge_->SetPermissionInfo(list);
207 207
208 // There should be two subviews per permission: a label and a select box. 208 // There should be three subviews per permission (an icon, a label and a
209 NSArray* subviews = [[controller_ permissionsContentView] subviews]; 209 // select box), plus a text label for the Permission section.
210 EXPECT_EQ(arraysize(kTestPermissionTypes) * 2, [subviews count]); 210 NSArray* subviews = [[controller_ permissionsView] subviews];
211 EXPECT_EQ(arraysize(kTestPermissionTypes) * 3 + 1, [subviews count]);
211 212
212 // Ensure that there is a distinct label for each permission. 213 // Ensure that there is a distinct label for each permission.
213 NSMutableSet* labels = [NSMutableSet set]; 214 NSMutableSet* labels = [NSMutableSet set];
214 for (NSView* view in subviews) { 215 for (NSView* view in subviews) {
215 if ([view isKindOfClass:[NSTextField class]]) 216 if ([view isKindOfClass:[NSTextField class]])
216 [labels addObject:[static_cast<NSTextField*>(view) stringValue]]; 217 [labels addObject:[static_cast<NSTextField*>(view) stringValue]];
217 } 218 }
218 EXPECT_EQ(arraysize(kTestPermissionTypes), [labels count]); 219 // The section header ("Permissions") will also be found, hence the +1.
220 EXPECT_EQ(arraysize(kTestPermissionTypes) + 1, [labels count]);
219 221
220 // Find the first permission pop-up button 222 // Find the first permission pop-up button
221 NSPopUpButton* button = nil; 223 NSPopUpButton* button = nil;
222 for (NSView* view in subviews) { 224 for (NSView* view in subviews) {
223 if ([view isKindOfClass:[NSPopUpButton class]]) { 225 if ([view isKindOfClass:[NSPopUpButton class]]) {
224 button = static_cast<NSPopUpButton*>(view); 226 button = static_cast<NSPopUpButton*>(view);
225 break; 227 break;
226 } 228 }
227 } 229 }
228 ASSERT_NSNE(nil, button); 230 ASSERT_NSNE(nil, button);
229 231
230 // Check that the button title is updated when the setting is changed. 232 // Check that the button title is updated when the setting is changed.
231 233
232 NSString* original_title = [[[button cell] menuItem] title]; 234 NSString* original_title = [[[button cell] menuItem] title];
233 [button selectItemAtIndex:kMenuIndexContentSettingBlock]; 235 [button selectItemAtIndex:kMenuIndexContentSettingBlock];
234 [controller_ permissionValueChanged:button]; 236 [controller_ permissionValueChanged:button];
235 EXPECT_NSNE(original_title, [[[button cell] menuItem] title]); 237 EXPECT_NSNE(original_title, [[[button cell] menuItem] title]);
236 238
237 [button selectItemAtIndex:kMenuIndexContentSettingDefault]; 239 [button selectItemAtIndex:kMenuIndexContentSettingDefault];
238 [controller_ permissionValueChanged:button]; 240 [controller_ permissionValueChanged:button];
239 EXPECT_NSNE(original_title, [[[button cell] menuItem] title]); 241 EXPECT_NSNE(original_title, [[[button cell] menuItem] title]);
240 242
241 [button selectItemAtIndex:kMenuIndexContentSettingAllow]; 243 [button selectItemAtIndex:kMenuIndexContentSettingAllow];
242 [controller_ permissionValueChanged:button]; 244 [controller_ permissionValueChanged:button];
243 EXPECT_NSEQ(original_title, [[[button cell] menuItem] title]); 245 EXPECT_NSEQ(original_title, [[[button cell] menuItem] title]);
244 } 246 }
245 247
246 } // namespace 248 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698