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

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

Issue 14655009: Client changes for disabled dasher account (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
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 "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/signin/fake_signin_manager.h" 10 #include "chrome/browser/signin/fake_signin_manager.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 // When switching back to unmanaged, the state should change, but the service 440 // When switching back to unmanaged, the state should change, but the service
441 // should not start up automatically (kSyncSetupCompleted will be false). 441 // should not start up automatically (kSyncSetupCompleted will be false).
442 Mock::VerifyAndClearExpectations(data_type_manager); 442 Mock::VerifyAndClearExpectations(data_type_manager);
443 EXPECT_CALL(*sync_->components_factory_mock(), 443 EXPECT_CALL(*sync_->components_factory_mock(),
444 CreateDataTypeManager(_, _, _, _, _)).Times(0); 444 CreateDataTypeManager(_, _, _, _, _)).Times(0);
445 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); 445 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
446 profile_->GetPrefs()->ClearPref(prefs::kSyncManaged); 446 profile_->GetPrefs()->ClearPref(prefs::kSyncManaged);
447 } 447 }
448 448
449 TEST_F(ProfileSyncServiceStartupTest, DisabledByAdminStartup) {
450 // Disable sync through policy.
451 profile_->GetPrefs()->SetBoolean(prefs::kSyncDisabledByAdmin, true);
452
453 EXPECT_CALL(*sync_->components_factory_mock(),
454 CreateDataTypeManager(_, _, _, _, _)).Times(0);
455 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
456
457 // Service should not be started by Initialize() since it's managed.
458 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
459 GaiaConstants::kSyncService, "sync_token");
460 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "test_user");
461 sync_->Initialize();
462 }
463
449 TEST_F(ProfileSyncServiceStartupTest, StartFailure) { 464 TEST_F(ProfileSyncServiceStartupTest, StartFailure) {
450 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); 465 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
451 DataTypeManager::ConfigureStatus status = DataTypeManager::ABORTED; 466 DataTypeManager::ConfigureStatus status = DataTypeManager::ABORTED;
452 syncer::SyncError error( 467 syncer::SyncError error(
453 FROM_HERE, "Association failed.", syncer::BOOKMARKS); 468 FROM_HERE, "Association failed.", syncer::BOOKMARKS);
454 std::list<syncer::SyncError> errors; 469 std::list<syncer::SyncError> errors;
455 errors.push_back(error); 470 errors.push_back(error);
456 DataTypeManager::ConfigureResult result( 471 DataTypeManager::ConfigureResult result(
457 status, 472 status,
458 syncer::ModelTypeSet(), 473 syncer::ModelTypeSet(),
(...skipping 22 matching lines...) Expand all
481 496
482 // Preload the tokens. 497 // Preload the tokens.
483 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 498 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
484 GaiaConstants::kSyncService, "sync_token"); 499 GaiaConstants::kSyncService, "sync_token");
485 sync_->fail_initial_download(); 500 sync_->fail_initial_download();
486 501
487 sync_->Initialize(); 502 sync_->Initialize();
488 EXPECT_FALSE(sync_->sync_initialized()); 503 EXPECT_FALSE(sync_->sync_initialized());
489 EXPECT_FALSE(sync_->GetBackendForTest()); 504 EXPECT_FALSE(sync_->GetBackendForTest());
490 } 505 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698