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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm

Issue 2286993002: [Material][Mac] Update the User Account Button (Closed)
Patch Set: fixed test Created 4 years, 3 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
OLDNEW
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/profiles/avatar_button_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/profiles/profiles_state.h" 12 #include "chrome/browser/profiles/profiles_state.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" 15 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
16 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 16 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
17 #include "chrome/browser/ui/cocoa/info_bubble_window.h" 17 #include "chrome/browser/ui/cocoa/info_bubble_window.h"
18 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 18 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
21 #include "chrome/grit/theme_resources.h" 21 #include "chrome/grit/theme_resources.h"
22 #include "components/signin/core/common/profile_management_switches.h" 22 #include "components/signin/core/common/profile_management_switches.h"
23 #import "testing/gtest_mac.h" 23 #import "testing/gtest_mac.h"
24 #include "ui/base/material_design/material_design_controller.h"
24 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
25 26
26 // Defined in the AvatarButtonController implementation. 27 // Defined in the AvatarButtonController implementation.
27 @interface AvatarButtonController (ExposedForTesting) 28 @interface AvatarButtonController (ExposedForTesting)
28 - (void)setErrorStatus:(BOOL)hasError; 29 - (void)setErrorStatus:(BOOL)hasError;
29 @end 30 @end
30 31
31 // Subclassing AvatarButtonController to be able to control the state of 32 // Subclassing AvatarButtonController to be able to control the state of
32 // keyboard modifierFlags. 33 // keyboard modifierFlags.
33 @interface AvatarButtonControllerForTesting : AvatarButtonController { 34 @interface AvatarButtonControllerForTesting : AvatarButtonController {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 TEST_F(AvatarButtonControllerTest, ProfileButtonWithErrorShown) { 100 TEST_F(AvatarButtonControllerTest, ProfileButtonWithErrorShown) {
100 // Create a second profile, to force the button to display the profile name. 101 // Create a second profile, to force the button to display the profile name.
101 testing_profile_manager()->CreateTestingProfile("batman"); 102 testing_profile_manager()->CreateTestingProfile("batman");
102 103
103 EXPECT_EQ(0, [button() image].size.width); 104 EXPECT_EQ(0, [button() image].size.width);
104 [controller() setErrorStatus:true]; 105 [controller() setErrorStatus:true];
105 106
106 ASSERT_FALSE([view() isHidden]); 107 ASSERT_FALSE([view() isHidden]);
107 EXPECT_NSEQ(@"Person 1", [button() title]); 108 EXPECT_NSEQ(@"Person 1", [button() title]);
108 109
109 // If the button has an authentication error, it should display an error icon. 110 // If the button has an authentication error, it should display an error
110 int errorWidth = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 111 // icon. If in the MD, the icon size should be 16.
111 IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR).Width(); 112 int errorWidth =
113 ui::MaterialDesignController::IsModeMaterial()
114 ? 16
115 : ui::ResourceBundle::GetSharedInstance()
116 .GetNativeImageNamed(IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR)
117 .Width();
118
112 EXPECT_EQ(errorWidth, [button() image].size.width); 119 EXPECT_EQ(errorWidth, [button() image].size.width);
113 } 120 }
114 121
115 TEST_F(AvatarButtonControllerTest, DoubleOpen) { 122 TEST_F(AvatarButtonControllerTest, DoubleOpen) {
116 EXPECT_FALSE([controller() menuController]); 123 EXPECT_FALSE([controller() menuController]);
117 124
118 [button() performClick:button()]; 125 [button() performClick:button()];
119 126
120 BaseBubbleController* menu = [controller() menuController]; 127 BaseBubbleController* menu = [controller() menuController];
121 EXPECT_TRUE(menu); 128 EXPECT_TRUE(menu);
(...skipping 30 matching lines...) Expand all
152 BaseBubbleController* menu = [controller() menuController]; 159 BaseBubbleController* menu = [controller() menuController];
153 EXPECT_TRUE(menu); 160 EXPECT_TRUE(menu);
154 EXPECT_TRUE([menu isKindOfClass:[ProfileChooserController class]]); 161 EXPECT_TRUE([menu isKindOfClass:[ProfileChooserController class]]);
155 162
156 // Do not animate out because that is hard to test around. 163 // Do not animate out because that is hard to test around.
157 static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations = 164 static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations =
158 info_bubble::kAnimateNone; 165 info_bubble::kAnimateNone;
159 [menu close]; 166 [menu close];
160 EXPECT_FALSE([controller() menuController]); 167 EXPECT_FALSE([controller() menuController]);
161 } 168 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm ('k') | ui/gfx/vector_icons/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698