Index: chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm |
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm |
index 635697807076b15bf3ae00af4c569de2368d14d1..c489af9b163cb382a4b6548471d8b188acd5166a 100644 |
--- a/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm |
+++ b/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm |
@@ -7,6 +7,7 @@ |
#include "base/command_line.h" |
#include "base/mac/scoped_nsobject.h" |
#include "base/strings/sys_string_conversions.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/profiles/profiles_state.h" |
#include "chrome/browser/ui/browser.h" |
@@ -18,7 +19,9 @@ |
#include "chrome/common/chrome_switches.h" |
#include "chrome/grit/generated_resources.h" |
#include "components/signin/core/common/profile_management_switches.h" |
+#include "grit/theme_resources.h" |
#include "ui/base/l10n/l10n_util.h" |
+#include "ui/base/resource/resource_bundle.h" |
class AvatarButtonControllerTest : public CocoaProfileTest { |
public: |
@@ -48,12 +51,40 @@ class AvatarButtonControllerTest : public CocoaProfileTest { |
base::scoped_nsobject<AvatarButtonController> controller_; |
}; |
-TEST_F(AvatarButtonControllerTest, ButtonShown) { |
+TEST_F(AvatarButtonControllerTest, GenericButtonShown) { |
EXPECT_FALSE([view() isHidden]); |
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME), |
+ // We only have one local profile, which means we are displaying the |
groby-ooo-7-16
2014/09/29 17:55:43
Nit: un-"we", if possible?
noms (inactive)
2014/09/29 19:21:57
Done.
|
+ // generic avatar button. |
+ EXPECT_EQ(base::string16(), base::SysNSStringToUTF16([button() title])); |
groby-ooo-7-16
2014/09/29 17:55:43
EXPECT_NSEQ(@"", [button() title]);
noms (inactive)
2014/09/29 19:21:57
Oh, cool! Done.
On 2014/09/29 17:55:43, groby wrot
|
+} |
+ |
+TEST_F(AvatarButtonControllerTest, ProfileButtonShown) { |
+ // Create a second profile, to force the button to display the profile name. |
+ testing_profile_manager()->CreateTestingProfile("batman"); |
+ |
+ EXPECT_FALSE([view() isHidden]); |
groby-ooo-7-16
2014/09/29 17:55:43
Why is that an expect? Should that be ASSERT_FALSE
noms (inactive)
2014/09/29 19:21:57
Done.
|
+ EXPECT_EQ(base::ASCIIToUTF16("Person 1"), |
groby-ooo-7-16
2014/09/29 17:55:43
EXPECT_NSEQ - here and elsewhere
noms (inactive)
2014/09/29 19:21:57
Done.
|
base::SysNSStringToUTF16([button() title])); |
} |
+TEST_F(AvatarButtonControllerTest, ProfileButtonWithErrorShown) { |
+ // Create a second profile, to force the button to display the profile name. |
+ testing_profile_manager()->CreateTestingProfile("batman"); |
+ |
+ EXPECT_EQ(0, [button() image].size.width); |
+ [controller() updateErrorStatus:true]; |
+ |
+ EXPECT_FALSE([view() isHidden]); |
+ EXPECT_EQ(base::ASCIIToUTF16("Person 1"), |
+ base::SysNSStringToUTF16([button() title])); |
+ |
+ // If the button has an authentication error, it should display an error icon. |
+ int errorWidth = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
+ IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR).Width(); |
+ EXPECT_LT(0, [button() image].size.width); |
groby-ooo-7-16
2014/09/29 17:55:43
Isn't that encapsulated in the EXPECT_EQ?
noms (inactive)
2014/09/29 19:21:57
I was really paranoid that maybe IDR_ICON.. would
|
+ EXPECT_EQ(errorWidth, [button() image].size.width); |
+} |
+ |
TEST_F(AvatarButtonControllerTest, DoubleOpen) { |
EXPECT_FALSE([controller() menuController]); |