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

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

Issue 476993002: [Profiles] Fix the usage of custom/default names and avatars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all rebase all the time Created 6 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 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 "chrome/browser/profiles/profiles_state.h" 10 #include "chrome/browser/profiles/profiles_state.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" 14 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
16 #include "chrome/browser/ui/cocoa/info_bubble_window.h" 16 #include "chrome/browser/ui/cocoa/info_bubble_window.h"
17 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 17 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "components/signin/core/common/profile_management_switches.h" 19 #include "components/signin/core/common/profile_management_switches.h"
20 20 #include "grit/generated_resources.h"
21 const char kDefaultProfileName[] = "default"; 21 #include "ui/base/l10n/l10n_util.h"
22 22
23 class AvatarButtonControllerTest : public CocoaProfileTest { 23 class AvatarButtonControllerTest : public CocoaProfileTest {
24 public: 24 public:
25 virtual void SetUp() OVERRIDE { 25 virtual void SetUp() OVERRIDE {
26 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); 26 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
27 DCHECK(profiles::IsMultipleProfilesEnabled()); 27 DCHECK(profiles::IsMultipleProfilesEnabled());
28 28
29 CocoaProfileTest::SetUp(); 29 CocoaProfileTest::SetUp();
30 ASSERT_TRUE(browser()); 30 ASSERT_TRUE(browser());
31 31
(...skipping 11 matching lines...) Expand all
43 NSView* view() { return [controller_ view]; } 43 NSView* view() { return [controller_ view]; }
44 44
45 AvatarButtonController* controller() { return controller_.get(); } 45 AvatarButtonController* controller() { return controller_.get(); }
46 46
47 private: 47 private:
48 base::scoped_nsobject<AvatarButtonController> controller_; 48 base::scoped_nsobject<AvatarButtonController> controller_;
49 }; 49 };
50 50
51 TEST_F(AvatarButtonControllerTest, ButtonShown) { 51 TEST_F(AvatarButtonControllerTest, ButtonShown) {
52 EXPECT_FALSE([view() isHidden]); 52 EXPECT_FALSE([view() isHidden]);
53 EXPECT_EQ(kDefaultProfileName, base::SysNSStringToUTF8([button() title])); 53 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME),
54 base::SysNSStringToUTF16([button() title]));
54 } 55 }
55 56
56 TEST_F(AvatarButtonControllerTest, DoubleOpen) { 57 TEST_F(AvatarButtonControllerTest, DoubleOpen) {
57 EXPECT_FALSE([controller() menuController]); 58 EXPECT_FALSE([controller() menuController]);
58 59
59 [button() performClick:button()]; 60 [button() performClick:button()];
60 61
61 BaseBubbleController* menu = [controller() menuController]; 62 BaseBubbleController* menu = [controller() menuController];
62 EXPECT_TRUE(menu); 63 EXPECT_TRUE(menu);
63 EXPECT_TRUE([menu isKindOfClass:[ProfileChooserController class]]); 64 EXPECT_TRUE([menu isKindOfClass:[ProfileChooserController class]]);
64 65
65 [button() performClick:button()]; 66 [button() performClick:button()];
66 EXPECT_EQ(menu, [controller() menuController]); 67 EXPECT_EQ(menu, [controller() menuController]);
67 68
68 // Do not animate out because that is hard to test around. 69 // Do not animate out because that is hard to test around.
69 static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations = 70 static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations =
70 info_bubble::kAnimateNone; 71 info_bubble::kAnimateNone;
71 [menu close]; 72 [menu close];
72 EXPECT_FALSE([controller() menuController]); 73 EXPECT_FALSE([controller() menuController]);
73 } 74 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profiles_state.cc ('k') | chrome/browser/ui/webui/options/manage_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698