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

Unified Diff: chrome/browser/sync/profile_sync_service_startup_unittest.cc

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/profile_sync_service_startup_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
index f1bfd968a84df71dc57b6516847a55ccc871174e..a1bdf31412fcdf4784fc3ba1cebfc3ff6c04db8c 100644
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -68,6 +68,11 @@ class FakeTokenService : public TokenService {
content::Source<TokenService>(this),
content::NotificationService::NoDetails());
}
+
+ static BrowserContextKeyedService* BuildFakeTokenService(
+ content::BrowserContext* profile) {
+ return new FakeTokenService();
+ }
};
class ProfileSyncServiceStartupTest : public testing::Test {
@@ -76,28 +81,35 @@ class ProfileSyncServiceStartupTest : public testing::Test {
: thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD |
content::TestBrowserThreadBundle::REAL_FILE_THREAD |
content::TestBrowserThreadBundle::REAL_IO_THREAD),
- profile_(new TestingProfile),
sync_(NULL) {}
virtual ~ProfileSyncServiceStartupTest() {
}
virtual void SetUp() {
+ profile_ = CreateProfile();
+ }
+
+ virtual scoped_ptr<TestingProfile> CreateProfile() {
+ TestingProfile::Builder builder;
#if defined(OS_CHROMEOS)
- SigninManagerFactory::GetInstance()->SetTestingFactory(
- profile_.get(), FakeSigninManagerBase::Build);
+ builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
+ FakeSigninManagerBase::Build);
#else
- SigninManagerFactory::GetInstance()->SetTestingFactory(
- profile_.get(), FakeSigninManager::Build);
+ builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
+ FakeSigninManager::Build);
#endif
+ builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
+ FakeOAuth2TokenService::BuildTokenService);
+ builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(),
+ BuildService);
+ builder.AddTestingFactory(TokenServiceFactory::GetInstance(),
+ FakeTokenService::BuildFakeTokenService);
+ return builder.Build();
}
virtual void TearDown() {
sync_->RemoveObserver(&observer_);
- ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(
- profile_.get(), NULL);
- ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
- profile_.get(), NULL);
profile_.reset();
// Pump messages posted by the sync core thread (which may end up
@@ -118,11 +130,8 @@ class ProfileSyncServiceStartupTest : public testing::Test {
}
void CreateSyncService() {
- ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
- profile_.get(), FakeOAuth2TokenService::BuildTokenService);
sync_ = static_cast<TestProfileSyncService*>(
- ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(), BuildService));
+ ProfileSyncServiceFactory::GetForProfile(profile_.get()));
sync_->AddObserver(&observer_);
sync_->set_synchronous_sync_configuration();
}
@@ -146,8 +155,6 @@ class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
public:
virtual void SetUp() {
ProfileSyncServiceStartupTest::SetUp();
- ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
- profile_.get(), FakeOAuth2TokenService::BuildTokenService);
sync_ = static_cast<TestProfileSyncService*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), BuildCrosService));
@@ -173,11 +180,6 @@ class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
}
};
-BrowserContextKeyedService* BuildFakeTokenService(
- content::BrowserContext* profile) {
- return new FakeTokenService();
-}
-
TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
// We've never completed startup.
profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
@@ -235,8 +237,7 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) {
SigninManagerFactory::GetForProfile(
profile_.get())->Initialize(profile_.get(), NULL);
TokenService* token_service = static_cast<TokenService*>(
- TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(), BuildFakeTokenService));
+ TokenServiceFactory::GetForProfile(profile_.get()));
CreateSyncService();
// Should not actually start, rather just clean things up and wait
@@ -327,8 +328,7 @@ TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) {
profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
TokenService* token_service = static_cast<TokenService*>(
- TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(), BuildFakeTokenService));
+ TokenServiceFactory::GetForProfile(profile_.get()));
sync_->Initialize();
// Sync should not start because there are no tokens yet.

Powered by Google App Engine
This is Rietveld 408576698