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

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

Issue 2673183002: [Mac] Test for avatar bubble alignment logic (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/profile_chooser_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
11 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/gcm/fake_gcm_profile_service.h" 15 #include "chrome/browser/gcm/fake_gcm_profile_service.h"
16 #include "chrome/browser/gcm/gcm_profile_service_factory.h" 16 #include "chrome/browser/gcm/gcm_profile_service_factory.h"
17 #include "chrome/browser/profiles/avatar_menu.h" 17 #include "chrome/browser/profiles/avatar_menu.h"
18 #include "chrome/browser/profiles/profile_attributes_entry.h" 18 #include "chrome/browser/profiles/profile_attributes_entry.h"
19 #include "chrome/browser/profiles/profile_attributes_storage.h" 19 #include "chrome/browser/profiles/profile_attributes_storage.h"
20 #include "chrome/browser/signin/account_fetcher_service_factory.h" 20 #include "chrome/browser/signin/account_fetcher_service_factory.h"
21 #include "chrome/browser/signin/account_tracker_service_factory.h" 21 #include "chrome/browser/signin/account_tracker_service_factory.h"
22 #include "chrome/browser/signin/chrome_signin_helper.h" 22 #include "chrome/browser/signin/chrome_signin_helper.h"
23 #include "chrome/browser/signin/fake_account_fetcher_service_builder.h" 23 #include "chrome/browser/signin/fake_account_fetcher_service_builder.h"
24 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" 24 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
26 #include "chrome/browser/signin/signin_manager_factory.h" 26 #include "chrome/browser/signin/signin_manager_factory.h"
27 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
28 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
29 #include "chrome/browser/ui/cocoa/l10n_util.h"
28 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" 30 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h"
31 #include "chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h"
29 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
31 #include "components/signin/core/browser/fake_account_fetcher_service.h" 34 #include "components/signin/core/browser/fake_account_fetcher_service.h"
32 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" 35 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
33 #include "components/signin/core/browser/profile_oauth2_token_service.h" 36 #include "components/signin/core/browser/profile_oauth2_token_service.h"
34 #include "components/signin/core/browser/signin_manager.h" 37 #include "components/signin/core/browser/signin_manager.h"
35 #include "components/signin/core/common/profile_management_switches.h" 38 #include "components/signin/core/common/profile_management_switches.h"
36 #include "components/signin/core/common/signin_pref_names.h" 39 #include "components/signin/core/common/signin_pref_names.h"
37 #include "components/sync_preferences/pref_service_syncable.h" 40 #include "components/sync_preferences/pref_service_syncable.h"
38 41
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 NSButton* link = base::mac::ObjCCast<NSButton>( 247 NSButton* link = base::mac::ObjCCast<NSButton>(
245 [linksSubviews objectAtIndex:0]); 248 [linksSubviews objectAtIndex:0]);
246 EXPECT_EQ(@selector(showInlineSigninPage:), [link action]); 249 EXPECT_EQ(@selector(showInlineSigninPage:), [link action]);
247 EXPECT_EQ(controller(), [link target]); 250 EXPECT_EQ(controller(), [link target]);
248 251
249 NSTextField* promo = base::mac::ObjCCast<NSTextField>( 252 NSTextField* promo = base::mac::ObjCCast<NSTextField>(
250 [linksSubviews objectAtIndex:1]); 253 [linksSubviews objectAtIndex:1]);
251 EXPECT_GT([[promo stringValue] length], 0U); 254 EXPECT_GT([[promo stringValue] length], 0U);
252 } 255 }
253 256
257 // Check to see if the bubble is aligned properly in LTR and RTL format.
258 TEST_F(ProfileChooserControllerTest, BubbleAlignment) {
259 // Test the LTR format.
260 StartProfileChooserController();
261 EXPECT_EQ(info_bubble::kAlignTrailingEdgeToAnchorEdge,
262 [[controller() bubble] alignment]);
263 [controller() close];
264
265 // Force to RTL format
266 cocoa_l10n_util::ScopedForceRTLMac rtl;
267 StartProfileChooserController();
268 info_bubble::BubbleAlignment expected_alignment =
269 cocoa_l10n_util::ShouldFlipWindowControlsInRTL()
270 ? info_bubble::kAlignTrailingEdgeToAnchorEdge
271 : info_bubble::kAlignLeadingEdgeToAnchorEdge;
272 EXPECT_EQ(expected_alignment, [[controller() bubble] alignment]);
273 [controller() close];
274 }
275
254 TEST_F(ProfileChooserControllerTest, RightClickTutorialShownAfterWelcome) { 276 TEST_F(ProfileChooserControllerTest, RightClickTutorialShownAfterWelcome) {
255 // The welcome upgrade tutorial takes precedence so show it then dismiss it. 277 // The welcome upgrade tutorial takes precedence so show it then dismiss it.
256 // The right click tutorial should be shown right away. 278 // The right click tutorial should be shown right away.
257 StartProfileChooserControllerWithTutorialMode( 279 StartProfileChooserControllerWithTutorialMode(
258 profiles::TUTORIAL_MODE_WELCOME_UPGRADE); 280 profiles::TUTORIAL_MODE_WELCOME_UPGRADE);
259 281
260 [controller() dismissTutorial:nil]; 282 [controller() dismissTutorial:nil];
261 AssertRightClickTutorialShown(); 283 AssertRightClickTutorialShown();
262 } 284 }
263 285
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 655 }
634 656
635 // There should be a lock button. 657 // There should be a lock button.
636 NSButton* lockButton = 658 NSButton* lockButton =
637 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); 659 base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
638 ASSERT_TRUE(lockButton); 660 ASSERT_TRUE(lockButton);
639 EXPECT_EQ(@selector(lockProfile:), [lockButton action]); 661 EXPECT_EQ(@selector(lockProfile:), [lockButton action]);
640 EXPECT_EQ(controller(), [lockButton target]); 662 EXPECT_EQ(controller(), [lockButton target]);
641 EXPECT_TRUE([lockButton isEnabled]); 663 EXPECT_TRUE([lockButton isEnabled]);
642 } 664 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698