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

Side by Side Diff: chrome/browser/app_controller_mac_unittest.mm

Issue 964563002: Replace SetAuthenticatedUsername with SetAuthenticatedAccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@priv
Patch Set: rebased Created 5 years, 8 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 shouldShow:NO 117 shouldShow:NO
118 currentProfile:profile_]; 118 currentProfile:profile_];
119 EXPECT_TRUE([[syncMenuItem title] isEqualTo:startSignin]); 119 EXPECT_TRUE([[syncMenuItem title] isEqualTo:startSignin]);
120 EXPECT_TRUE([syncMenuItem isHidden]); 120 EXPECT_TRUE([syncMenuItem isHidden]);
121 121
122 // Now sign in. 122 // Now sign in.
123 std::string username = "foo@example.com"; 123 std::string username = "foo@example.com";
124 NSString* alreadySignedIn = l10n_util::GetNSStringFWithFixup( 124 NSString* alreadySignedIn = l10n_util::GetNSStringFWithFixup(
125 IDS_SYNC_MENU_SYNCED_LABEL, base::UTF8ToUTF16(username)); 125 IDS_SYNC_MENU_SYNCED_LABEL, base::UTF8ToUTF16(username));
126 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 126 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
127 signin->SetAuthenticatedUsername(username); 127 signin->SetAuthenticatedAccountInfo(username, username);
128 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(profile_); 128 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(profile_);
129 sync->SetSyncSetupCompleted(); 129 sync->SetSyncSetupCompleted();
130 [AppController updateSigninItem:syncMenuItem 130 [AppController updateSigninItem:syncMenuItem
131 shouldShow:YES 131 shouldShow:YES
132 currentProfile:profile_]; 132 currentProfile:profile_];
133 EXPECT_TRUE([[syncMenuItem title] isEqualTo:alreadySignedIn]); 133 EXPECT_TRUE([[syncMenuItem title] isEqualTo:alreadySignedIn]);
134 EXPECT_FALSE([syncMenuItem isHidden]); 134 EXPECT_FALSE([syncMenuItem isHidden]);
135 } 135 }
136 136
137 TEST_F(AppControllerTest, TestSigninMenuItemAuthError) { 137 TEST_F(AppControllerTest, TestSigninMenuItemAuthError) {
138 base::scoped_nsobject<NSMenuItem> syncMenuItem( 138 base::scoped_nsobject<NSMenuItem> syncMenuItem(
139 [[NSMenuItem alloc] initWithTitle:@"" 139 [[NSMenuItem alloc] initWithTitle:@""
140 action:@selector(commandDispatch) 140 action:@selector(commandDispatch)
141 keyEquivalent:@""]); 141 keyEquivalent:@""]);
142 [syncMenuItem setTag:IDC_SHOW_SYNC_SETUP]; 142 [syncMenuItem setTag:IDC_SHOW_SYNC_SETUP];
143 143
144 // Now sign in. 144 // Now sign in.
145 std::string username = "foo@example.com"; 145 std::string username = "foo@example.com";
146 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 146 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
147 signin->SetAuthenticatedUsername(username); 147 signin->SetAuthenticatedAccountInfo(username, username);
148 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(profile_); 148 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(profile_);
149 sync->SetSyncSetupCompleted(); 149 sync->SetSyncSetupCompleted();
150 // Force an auth error. 150 // Force an auth error.
151 FakeAuthStatusProvider provider( 151 FakeAuthStatusProvider provider(
152 SigninErrorControllerFactory::GetForProfile(profile_)); 152 SigninErrorControllerFactory::GetForProfile(profile_));
153 GoogleServiceAuthError error( 153 GoogleServiceAuthError error(
154 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 154 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
155 provider.SetAuthError("user@gmail.com", "user@gmail.com", error); 155 provider.SetAuthError("user@gmail.com", "user@gmail.com", error);
156 [AppController updateSigninItem:syncMenuItem 156 [AppController updateSigninItem:syncMenuItem
157 shouldShow:YES 157 shouldShow:YES
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 [followingNonSeparator setHidden:YES]; 218 [followingNonSeparator setHidden:YES];
219 [AppController updateSigninItem:signinMenuItem 219 [AppController updateSigninItem:signinMenuItem
220 shouldShow:YES 220 shouldShow:YES
221 currentProfile:profile_]; 221 currentProfile:profile_];
222 222
223 EXPECT_TRUE([followingNonSeparator isEnabled]); 223 EXPECT_TRUE([followingNonSeparator isEnabled]);
224 EXPECT_FALSE([signinMenuItem isHidden]); 224 EXPECT_FALSE([signinMenuItem isHidden]);
225 EXPECT_TRUE([followingNonSeparator isHidden]); 225 EXPECT_TRUE([followingNonSeparator isHidden]);
226 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698