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

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

Issue 2174973002: [Mac][MD User Menu] Revamped signin/sync error surfacing UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After refactoring Created 4 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
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 "components/signin/core/common/profile_management_switches.h" 21 #include "components/signin/core/common/profile_management_switches.h"
22 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
23 #import "testing/gtest_mac.h" 23 #import "testing/gtest_mac.h"
24 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
26 26
27 // Defined in the AvatarButtonController implementation. 27 // Defined in the AvatarButtonController implementation.
28 @interface AvatarButtonController (ExposedForTesting) 28 @interface AvatarButtonController (ExposedForTesting)
29 - (void)updateErrorStatus:(BOOL)hasError; 29 - (void)setErrorStatus:(BOOL)hasError;
30 @end 30 @end
31 31
32 // Subclassing AvatarButtonController to be able to control the state of 32 // Subclassing AvatarButtonController to be able to control the state of
33 // keyboard modifierFlags. 33 // keyboard modifierFlags.
34 @interface AvatarButtonControllerForTesting : AvatarButtonController { 34 @interface AvatarButtonControllerForTesting : AvatarButtonController {
35 @private 35 @private
36 bool isCtrlPressed_; 36 bool isCtrlPressed_;
37 } 37 }
38 @end 38 @end
39 39
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 ASSERT_FALSE([view() isHidden]); 96 ASSERT_FALSE([view() isHidden]);
97 EXPECT_NSEQ(@"Person 1", [button() title]); 97 EXPECT_NSEQ(@"Person 1", [button() title]);
98 } 98 }
99 99
100 TEST_F(AvatarButtonControllerTest, ProfileButtonWithErrorShown) { 100 TEST_F(AvatarButtonControllerTest, ProfileButtonWithErrorShown) {
101 // 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.
102 testing_profile_manager()->CreateTestingProfile("batman"); 102 testing_profile_manager()->CreateTestingProfile("batman");
103 103
104 EXPECT_EQ(0, [button() image].size.width); 104 EXPECT_EQ(0, [button() image].size.width);
105 [controller() updateErrorStatus:true]; 105 [controller() setErrorStatus:true];
106 106
107 ASSERT_FALSE([view() isHidden]); 107 ASSERT_FALSE([view() isHidden]);
108 EXPECT_NSEQ(@"Person 1", [button() title]); 108 EXPECT_NSEQ(@"Person 1", [button() title]);
109 109
110 // 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 icon.
111 int errorWidth = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 111 int errorWidth = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
112 IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR).Width(); 112 IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR).Width();
113 EXPECT_EQ(errorWidth, [button() image].size.width); 113 EXPECT_EQ(errorWidth, [button() image].size.width);
114 } 114 }
115 115
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 BaseBubbleController* menu = [controller() menuController]; 153 BaseBubbleController* menu = [controller() menuController];
154 EXPECT_TRUE(menu); 154 EXPECT_TRUE(menu);
155 EXPECT_TRUE([menu isKindOfClass:[ProfileChooserController class]]); 155 EXPECT_TRUE([menu isKindOfClass:[ProfileChooserController class]]);
156 156
157 // Do not animate out because that is hard to test around. 157 // Do not animate out because that is hard to test around.
158 static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations = 158 static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations =
159 info_bubble::kAnimateNone; 159 info_bubble::kAnimateNone;
160 [menu close]; 160 [menu close];
161 EXPECT_FALSE([controller() menuController]); 161 EXPECT_FALSE([controller() menuController]);
162 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698