| OLD | NEW |
| 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 Loading... |
| 117 currentProfile:profile_]; | 117 currentProfile:profile_]; |
| 118 EXPECT_TRUE([[syncMenuItem title] isEqualTo:startSignin]); | 118 EXPECT_TRUE([[syncMenuItem title] isEqualTo:startSignin]); |
| 119 EXPECT_TRUE([syncMenuItem isHidden]); | 119 EXPECT_TRUE([syncMenuItem isHidden]); |
| 120 | 120 |
| 121 // Now sign in. | 121 // Now sign in. |
| 122 std::string username = "foo@example.com"; | 122 std::string username = "foo@example.com"; |
| 123 NSString* alreadySignedIn = l10n_util::GetNSStringFWithFixup( | 123 NSString* alreadySignedIn = l10n_util::GetNSStringFWithFixup( |
| 124 IDS_SYNC_MENU_SYNCED_LABEL, base::UTF8ToUTF16(username)); | 124 IDS_SYNC_MENU_SYNCED_LABEL, base::UTF8ToUTF16(username)); |
| 125 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 125 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
| 126 signin->SetAuthenticatedAccountInfo(username, username); | 126 signin->SetAuthenticatedAccountInfo(username, username); |
| 127 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(profile_); | 127 browser_sync::ProfileSyncService* sync = |
| 128 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 128 sync->SetFirstSetupComplete(); | 129 sync->SetFirstSetupComplete(); |
| 129 [AppController updateSigninItem:syncMenuItem | 130 [AppController updateSigninItem:syncMenuItem |
| 130 shouldShow:YES | 131 shouldShow:YES |
| 131 currentProfile:profile_]; | 132 currentProfile:profile_]; |
| 132 EXPECT_TRUE([[syncMenuItem title] isEqualTo:alreadySignedIn]); | 133 EXPECT_TRUE([[syncMenuItem title] isEqualTo:alreadySignedIn]); |
| 133 EXPECT_FALSE([syncMenuItem isHidden]); | 134 EXPECT_FALSE([syncMenuItem isHidden]); |
| 134 } | 135 } |
| 135 | 136 |
| 136 TEST_F(AppControllerTest, TestSigninMenuItemAuthError) { | 137 TEST_F(AppControllerTest, TestSigninMenuItemAuthError) { |
| 137 base::scoped_nsobject<NSMenuItem> syncMenuItem( | 138 base::scoped_nsobject<NSMenuItem> syncMenuItem( |
| 138 [[NSMenuItem alloc] initWithTitle:@"" | 139 [[NSMenuItem alloc] initWithTitle:@"" |
| 139 action:@selector(commandDispatch) | 140 action:@selector(commandDispatch) |
| 140 keyEquivalent:@""]); | 141 keyEquivalent:@""]); |
| 141 [syncMenuItem setTag:IDC_SHOW_SYNC_SETUP]; | 142 [syncMenuItem setTag:IDC_SHOW_SYNC_SETUP]; |
| 142 | 143 |
| 143 // Now sign in. | 144 // Now sign in. |
| 144 std::string username = "foo@example.com"; | 145 std::string username = "foo@example.com"; |
| 145 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 146 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
| 146 signin->SetAuthenticatedAccountInfo(username, username); | 147 signin->SetAuthenticatedAccountInfo(username, username); |
| 147 ProfileSyncService* sync = ProfileSyncServiceFactory::GetForProfile(profile_); | 148 browser_sync::ProfileSyncService* sync = |
| 149 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 148 sync->SetFirstSetupComplete(); | 150 sync->SetFirstSetupComplete(); |
| 149 // Force an auth error. | 151 // Force an auth error. |
| 150 FakeAuthStatusProvider provider( | 152 FakeAuthStatusProvider provider( |
| 151 SigninErrorControllerFactory::GetForProfile(profile_)); | 153 SigninErrorControllerFactory::GetForProfile(profile_)); |
| 152 GoogleServiceAuthError error( | 154 GoogleServiceAuthError error( |
| 153 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 155 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 154 provider.SetAuthError("user@gmail.com", error); | 156 provider.SetAuthError("user@gmail.com", error); |
| 155 [AppController updateSigninItem:syncMenuItem | 157 [AppController updateSigninItem:syncMenuItem |
| 156 shouldShow:YES | 158 shouldShow:YES |
| 157 currentProfile:profile_]; | 159 currentProfile:profile_]; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 218 |
| 217 [followingNonSeparator setHidden:YES]; | 219 [followingNonSeparator setHidden:YES]; |
| 218 [AppController updateSigninItem:signinMenuItem | 220 [AppController updateSigninItem:signinMenuItem |
| 219 shouldShow:YES | 221 shouldShow:YES |
| 220 currentProfile:profile_]; | 222 currentProfile:profile_]; |
| 221 | 223 |
| 222 EXPECT_TRUE([followingNonSeparator isEnabled]); | 224 EXPECT_TRUE([followingNonSeparator isEnabled]); |
| 223 EXPECT_FALSE([signinMenuItem isHidden]); | 225 EXPECT_FALSE([signinMenuItem isHidden]); |
| 224 EXPECT_TRUE([followingNonSeparator isHidden]); | 226 EXPECT_TRUE([followingNonSeparator isHidden]); |
| 225 } | 227 } |
| OLD | NEW |