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

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

Issue 10434009: No longer trigger SyncCredentialsLost flow on cros. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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.cc ('k') | 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 (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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/signin/signin_manager.h" 10 #include "chrome/browser/signin/signin_manager.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 157 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
158 GaiaConstants::kSyncService, "sync_token"); 158 GaiaConstants::kSyncService, "sync_token");
159 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 159 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
160 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); 160 GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token");
161 service_->set_setup_in_progress(false); 161 service_->set_setup_in_progress(false);
162 service_->OnUserChoseDatatypes( 162 service_->OnUserChoseDatatypes(
163 false, syncable::ModelTypeSet(syncable::BOOKMARKS)); 163 false, syncable::ModelTypeSet(syncable::BOOKMARKS));
164 EXPECT_TRUE(service_->ShouldPushChanges()); 164 EXPECT_TRUE(service_->ShouldPushChanges());
165 } 165 }
166 166
167 TEST_F(ProfileSyncServiceStartupTest, StartNoCredentials) {
168 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
169 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0);
170
171 // We've never completed startup.
172 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
173 // Make sure SigninManager doesn't think we're signed in (undoes the call to
174 // SetAuthenticatedUsername() in CreateSyncService()).
175 SigninManagerFactory::GetForProfile(profile_.get())->SignOut();
176
177 // Should not actually start, rather just clean things up and wait
178 // to be enabled.
179 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
180 service_->Initialize();
Nicolas Zea 2012/05/23 22:54:11 maybe add EXPECT_FALSE(GetBackendForTest()) to ens
Andrew T Wilson (Slow) 2012/05/23 23:44:53 Done.
181
182 // Preferences should be back to defaults.
183 EXPECT_EQ(0, profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime));
184 EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(prefs::kSyncHasSetupCompleted));
185 Mock::VerifyAndClearExpectations(data_type_manager);
186
187 // Then start things up.
188 EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(1);
189 EXPECT_CALL(*data_type_manager, state()).
190 WillOnce(Return(DataTypeManager::CONFIGURED)).
191 WillOnce(Return(DataTypeManager::CONFIGURED));
192 EXPECT_CALL(*data_type_manager, Stop()).Times(1);
193 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
194
195 service_->set_setup_in_progress(true);
196 service_->signin()->StartSignIn("test_user", "", "", "");
197 // NOTE: Unlike StartFirstTime, this test does not issue any auth tokens.
198 content::NotificationService::current()->Notify(
199 chrome::NOTIFICATION_TOKEN_LOADING_FINISHED,
200 content::Source<TokenService>(
201 TokenServiceFactory::GetForProfile(profile_.get())),
202 content::NotificationService::NoDetails());
203 service_->set_setup_in_progress(false);
204 service_->OnUserChoseDatatypes(
205 false, syncable::ModelTypeSet(syncable::BOOKMARKS));
206 // Backend should initialize using a bogus GAIA token for credentials.
207 EXPECT_TRUE(service_->ShouldPushChanges());
208 }
209
210 TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) {
211 EXPECT_CALL(*factory_mock(), CreateDataTypeManager(_, _)).Times(0);
212 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
213 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
214
215 service_->Initialize();
Nicolas Zea 2012/05/23 22:54:11 after this too
Andrew T Wilson (Slow) 2012/05/23 23:44:53 Done.
216 // Sync should not start because there are no tokens yet.
217 EXPECT_FALSE(service_->ShouldPushChanges());
218 content::NotificationService::current()->Notify(
219 chrome::NOTIFICATION_TOKEN_LOADING_FINISHED,
220 content::Source<TokenService>(
221 TokenServiceFactory::GetForProfile(profile_.get())),
222 content::NotificationService::NoDetails());
223 service_->set_setup_in_progress(false);
224 // Sync should not start because there are still no tokens.
225 EXPECT_FALSE(service_->ShouldPushChanges());
Nicolas Zea 2012/05/23 22:54:11 and here
Andrew T Wilson (Slow) 2012/05/23 23:44:53 Done.
226 }
227
167 TEST_F(ProfileSyncServiceStartupCrosTest, StartFirstTime) { 228 TEST_F(ProfileSyncServiceStartupCrosTest, StartFirstTime) {
168 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); 229 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
169 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 230 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
170 EXPECT_CALL(*data_type_manager, Configure(_, _)); 231 EXPECT_CALL(*data_type_manager, Configure(_, _));
171 EXPECT_CALL(*data_type_manager, state()). 232 EXPECT_CALL(*data_type_manager, state()).
172 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); 233 WillRepeatedly(Return(DataTypeManager::CONFIGURED));
173 EXPECT_CALL(*data_type_manager, Stop()).Times(1); 234 EXPECT_CALL(*data_type_manager, Stop()).Times(1);
174 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); 235 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
175 236
176 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 237 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 399
339 // Preload the tokens. 400 // Preload the tokens.
340 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 401 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
341 GaiaConstants::kSyncService, "sync_token"); 402 GaiaConstants::kSyncService, "sync_token");
342 service_->fail_initial_download(); 403 service_->fail_initial_download();
343 404
344 service_->Initialize(); 405 service_->Initialize();
345 EXPECT_FALSE(service_->sync_initialized()); 406 EXPECT_FALSE(service_->sync_initialized());
346 EXPECT_FALSE(service_->GetBackendForTest()); 407 EXPECT_FALSE(service_->GetBackendForTest());
347 } 408 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698