| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 12 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "net/test/test_certificate_data.h" | 15 #include "net/test/test_certificate_data.h" |
| 14 #include "testing/gtest_mac.h" | 16 #include "testing/gtest_mac.h" |
| 15 | 17 |
| 16 @interface WebsiteSettingsBubbleController (ExposedForTesting) | 18 @interface WebsiteSettingsBubbleController (ExposedForTesting) |
| 17 - (NSView*)permissionsView; | 19 - (NSView*)permissionsView; |
| 18 - (NSButton*)resetDecisionsButton; | 20 - (NSButton*)resetDecisionsButton; |
| 19 - (NSButton*)securityDetailsButton; | 21 - (NSButton*)securityDetailsButton; |
| 20 @end | 22 @end |
| 21 | 23 |
| 22 @implementation WebsiteSettingsBubbleController (ExposedForTesting) | 24 @implementation WebsiteSettingsBubbleController (ExposedForTesting) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // If |default_width| is 0, the *default* default width will be used. | 127 // If |default_width| is 0, the *default* default width will be used. |
| 126 void CreateBubbleWithWidth(CGFloat default_width) { | 128 void CreateBubbleWithWidth(CGFloat default_width) { |
| 127 bridge_ = new WebsiteSettingsUIBridge(nullptr); | 129 bridge_ = new WebsiteSettingsUIBridge(nullptr); |
| 128 | 130 |
| 129 // The controller cleans up after itself when the window closes. | 131 // The controller cleans up after itself when the window closes. |
| 130 controller_ = [WebsiteSettingsBubbleControllerForTesting alloc]; | 132 controller_ = [WebsiteSettingsBubbleControllerForTesting alloc]; |
| 131 [controller_ setDefaultWindowWidth:default_width]; | 133 [controller_ setDefaultWindowWidth:default_width]; |
| 132 [controller_ initWithParentWindow:test_window() | 134 [controller_ initWithParentWindow:test_window() |
| 133 websiteSettingsUIBridge:bridge_ | 135 websiteSettingsUIBridge:bridge_ |
| 134 webContents:nil | 136 webContents:nil |
| 137 profile:&profile_ |
| 135 url:GURL("https://www.google.com") | 138 url:GURL("https://www.google.com") |
| 136 isDevToolsDisabled:NO]; | 139 isDevToolsDisabled:NO]; |
| 137 window_ = [controller_ window]; | 140 window_ = [controller_ window]; |
| 138 [controller_ showWindow:nil]; | 141 [controller_ showWindow:nil]; |
| 139 } | 142 } |
| 140 | 143 |
| 141 void CreateBubble() { | 144 void CreateBubble() { |
| 142 CreateBubbleWithWidth(0.0); | 145 CreateBubbleWithWidth(0.0); |
| 143 } | 146 } |
| 144 | 147 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if (info.setting == CONTENT_SETTING_DEFAULT) | 198 if (info.setting == CONTENT_SETTING_DEFAULT) |
| 196 info.default_setting = kTestDefaultSettings[i]; | 199 info.default_setting = kTestDefaultSettings[i]; |
| 197 info.source = kTestSettingSources[i]; | 200 info.source = kTestSettingSources[i]; |
| 198 info.is_incognito = false; | 201 info.is_incognito = false; |
| 199 permission_info_list.push_back(info); | 202 permission_info_list.push_back(info); |
| 200 } | 203 } |
| 201 ChosenObjectInfoList chosen_object_info_list; | 204 ChosenObjectInfoList chosen_object_info_list; |
| 202 bridge_->SetPermissionInfo(permission_info_list, chosen_object_info_list); | 205 bridge_->SetPermissionInfo(permission_info_list, chosen_object_info_list); |
| 203 } | 206 } |
| 204 | 207 |
| 208 content::TestBrowserThreadBundle thread_bundle_; |
| 209 TestingProfile profile_; |
| 210 |
| 205 WebsiteSettingsBubbleControllerForTesting* controller_; // Weak, owns self. | 211 WebsiteSettingsBubbleControllerForTesting* controller_; // Weak, owns self. |
| 206 NSWindow* window_; // Weak, owned by controller. | 212 NSWindow* window_; // Weak, owned by controller. |
| 207 }; | 213 }; |
| 208 | 214 |
| 209 TEST_F(WebsiteSettingsBubbleControllerTest, SecurityDetailsButton) { | 215 TEST_F(WebsiteSettingsBubbleControllerTest, SecurityDetailsButton) { |
| 210 WebsiteSettingsUI::IdentityInfo info; | 216 WebsiteSettingsUI::IdentityInfo info; |
| 211 info.site_identity = std::string("example.com"); | 217 info.site_identity = std::string("example.com"); |
| 212 info.identity_status = WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN; | 218 info.identity_status = WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN; |
| 213 | 219 |
| 214 CreateBubble(); | 220 CreateBubble(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 321 } |
| 316 if ([view isKindOfClass:[NSPopUpButton class]]) { | 322 if ([view isKindOfClass:[NSPopUpButton class]]) { |
| 317 NSPopUpButton* button = static_cast<NSPopUpButton*>(view); | 323 NSPopUpButton* button = static_cast<NSPopUpButton*>(view); |
| 318 EXPECT_LT(NSMaxX([button frame]), window_width); | 324 EXPECT_LT(NSMaxX([button frame]), window_width); |
| 319 } | 325 } |
| 320 } | 326 } |
| 321 } | 327 } |
| 322 } | 328 } |
| 323 | 329 |
| 324 } // namespace | 330 } // namespace |
| OLD | NEW |