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

Side by Side Diff: chrome/browser/sync/sync_global_error_unittest.cc

Issue 10696107: sync: Track validity of about:sync fields (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another rebase Created 8 years, 5 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
« no previous file with comments | « chrome/browser/sync/profile_sync_service_mock.h ('k') | chrome/browser/sync/sync_ui_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/sync/sync_global_error.h" 5 #include "chrome/browser/sync/sync_global_error.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/signin/signin_manager.h" 10 #include "chrome/browser/signin/signin_manager.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 scoped_ptr<Profile> profile( 138 scoped_ptr<Profile> profile(
139 ProfileSyncServiceMock::MakeSignedInTestingProfile()); 139 ProfileSyncServiceMock::MakeSignedInTestingProfile());
140 NiceMock<ProfileSyncServiceMock> service(profile.get()); 140 NiceMock<ProfileSyncServiceMock> service(profile.get());
141 SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get()); 141 SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get());
142 LoginUIServiceMock* login_ui_service = static_cast<LoginUIServiceMock*>( 142 LoginUIServiceMock* login_ui_service = static_cast<LoginUIServiceMock*>(
143 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse( 143 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse(
144 profile.get(), BuildMockLoginUIService)); 144 profile.get(), BuildMockLoginUIService));
145 SyncGlobalError error(&service, signin); 145 SyncGlobalError error(&service, signin);
146 146
147 browser_sync::SyncBackendHost::Status status; 147 browser_sync::SyncBackendHost::Status status;
148 EXPECT_CALL(service, QueryDetailedSyncStatus()) 148 EXPECT_CALL(service, QueryDetailedSyncStatus(_))
149 .WillRepeatedly(Return(status)); 149 .WillRepeatedly(Return(false));
150 150
151 EXPECT_CALL(service, IsPassphraseRequired()) 151 EXPECT_CALL(service, IsPassphraseRequired())
152 .WillRepeatedly(Return(true)); 152 .WillRepeatedly(Return(true));
153 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) 153 EXPECT_CALL(service, IsPassphraseRequiredForDecryption())
154 .WillRepeatedly(Return(true)); 154 .WillRepeatedly(Return(true));
155 VerifySyncGlobalErrorResult( 155 VerifySyncGlobalErrorResult(
156 &service, login_ui_service, browser(), &error, 156 &service, login_ui_service, browser(), &error,
157 GoogleServiceAuthError::NONE, true, true); 157 GoogleServiceAuthError::NONE, true, true);
158 } 158 }
159 159
160 // Test that SyncGlobalError shows an error for conditions that can be resolved 160 // Test that SyncGlobalError shows an error for conditions that can be resolved
161 // by the user and suppresses errors for conditions that cannot be resolved by 161 // by the user and suppresses errors for conditions that cannot be resolved by
162 // the user. 162 // the user.
163 TEST_F(SyncGlobalErrorTest, AuthStateGlobalError) { 163 TEST_F(SyncGlobalErrorTest, AuthStateGlobalError) {
164 scoped_ptr<Profile> profile( 164 scoped_ptr<Profile> profile(
165 ProfileSyncServiceMock::MakeSignedInTestingProfile()); 165 ProfileSyncServiceMock::MakeSignedInTestingProfile());
166 NiceMock<ProfileSyncServiceMock> service(profile.get()); 166 NiceMock<ProfileSyncServiceMock> service(profile.get());
167 SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get()); 167 SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get());
168 LoginUIServiceMock* login_ui_service = static_cast<LoginUIServiceMock*>( 168 LoginUIServiceMock* login_ui_service = static_cast<LoginUIServiceMock*>(
169 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse( 169 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse(
170 profile.get(), BuildMockLoginUIService)); 170 profile.get(), BuildMockLoginUIService));
171 SyncGlobalError error(&service, signin); 171 SyncGlobalError error(&service, signin);
172 172
173 browser_sync::SyncBackendHost::Status status; 173 browser_sync::SyncBackendHost::Status status;
174 EXPECT_CALL(service, QueryDetailedSyncStatus()) 174 EXPECT_CALL(service, QueryDetailedSyncStatus(_))
175 .WillRepeatedly(Return(status)); 175 .WillRepeatedly(Return(false));
176 176
177 struct { 177 struct {
178 GoogleServiceAuthError::State error_state; 178 GoogleServiceAuthError::State error_state;
179 bool is_error; 179 bool is_error;
180 } table[] = { 180 } table[] = {
181 { GoogleServiceAuthError::NONE, false }, 181 { GoogleServiceAuthError::NONE, false },
182 { GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, true }, 182 { GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, true },
183 { GoogleServiceAuthError::USER_NOT_SIGNED_UP, true }, 183 { GoogleServiceAuthError::USER_NOT_SIGNED_UP, true },
184 { GoogleServiceAuthError::CONNECTION_FAILED, false }, 184 { GoogleServiceAuthError::CONNECTION_FAILED, false },
185 { GoogleServiceAuthError::CAPTCHA_REQUIRED, true }, 185 { GoogleServiceAuthError::CAPTCHA_REQUIRED, true },
186 { GoogleServiceAuthError::ACCOUNT_DELETED, true }, 186 { GoogleServiceAuthError::ACCOUNT_DELETED, true },
187 { GoogleServiceAuthError::ACCOUNT_DISABLED, true }, 187 { GoogleServiceAuthError::ACCOUNT_DISABLED, true },
188 { GoogleServiceAuthError::SERVICE_UNAVAILABLE, true }, 188 { GoogleServiceAuthError::SERVICE_UNAVAILABLE, true },
189 { GoogleServiceAuthError::TWO_FACTOR, true }, 189 { GoogleServiceAuthError::TWO_FACTOR, true },
190 { GoogleServiceAuthError::REQUEST_CANCELED, true }, 190 { GoogleServiceAuthError::REQUEST_CANCELED, true },
191 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, 191 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true },
192 }; 192 };
193 193
194 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { 194 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) {
195 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, 195 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error,
196 table[i].error_state, true, table[i].is_error); 196 table[i].error_state, true, table[i].is_error);
197 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, 197 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error,
198 table[i].error_state, false, false); 198 table[i].error_state, false, false);
199 } 199 }
200 } 200 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_mock.h ('k') | chrome/browser/sync/sync_ui_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698