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

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

Issue 15517005: Remove references to Profile from browser_context_keyed_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & style 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 | Annotate | Revision Log
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 profile_.reset(); 98 profile_.reset();
99 99
100 // Pump messages posted by the sync core thread (which may end up 100 // Pump messages posted by the sync core thread (which may end up
101 // posting on the IO thread). 101 // posting on the IO thread).
102 ui_loop_.RunUntilIdle(); 102 ui_loop_.RunUntilIdle();
103 io_thread_.Stop(); 103 io_thread_.Stop();
104 file_thread_.Stop(); 104 file_thread_.Stop();
105 ui_loop_.RunUntilIdle(); 105 ui_loop_.RunUntilIdle();
106 } 106 }
107 107
108 static ProfileKeyedService* BuildService(content::BrowserContext* profile) { 108 static BrowserContextKeyedService* BuildService(
109 content::BrowserContext* profile) {
109 return new TestProfileSyncService( 110 return new TestProfileSyncService(
110 new ProfileSyncComponentsFactoryMock(), 111 new ProfileSyncComponentsFactoryMock(),
111 static_cast<Profile*>(profile), 112 static_cast<Profile*>(profile),
112 SigninManagerFactory::GetForProfile(static_cast<Profile*>(profile)), 113 SigninManagerFactory::GetForProfile(static_cast<Profile*>(profile)),
113 ProfileSyncService::MANUAL_START, 114 ProfileSyncService::MANUAL_START,
114 true); 115 true);
115 } 116 }
116 117
117 void CreateSyncService() { 118 void CreateSyncService() {
118 sync_ = static_cast<TestProfileSyncService*>( 119 sync_ = static_cast<TestProfileSyncService*>(
(...skipping 26 matching lines...) Expand all
145 public: 146 public:
146 virtual void SetUp() { 147 virtual void SetUp() {
147 ProfileSyncServiceStartupTest::SetUp(); 148 ProfileSyncServiceStartupTest::SetUp();
148 sync_ = static_cast<TestProfileSyncService*>( 149 sync_ = static_cast<TestProfileSyncService*>(
149 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 150 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
150 profile_.get(), BuildCrosService)); 151 profile_.get(), BuildCrosService));
151 sync_->AddObserver(&observer_); 152 sync_->AddObserver(&observer_);
152 sync_->set_synchronous_sync_configuration(); 153 sync_->set_synchronous_sync_configuration();
153 } 154 }
154 155
155 static ProfileKeyedService* BuildCrosService( 156 static BrowserContextKeyedService* BuildCrosService(
156 content::BrowserContext* context) { 157 content::BrowserContext* context) {
157 Profile* profile = static_cast<Profile*>(context); 158 Profile* profile = static_cast<Profile*>(context);
158 SigninManagerBase* signin = 159 SigninManagerBase* signin =
159 SigninManagerFactory::GetForProfile(profile); 160 SigninManagerFactory::GetForProfile(profile);
160 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, 161 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
161 "test_user"); 162 "test_user");
162 signin->Initialize(profile, NULL); 163 signin->Initialize(profile, NULL);
163 EXPECT_FALSE(signin->GetAuthenticatedUsername().empty()); 164 EXPECT_FALSE(signin->GetAuthenticatedUsername().empty());
164 return new TestProfileSyncService( 165 return new TestProfileSyncService(
165 new ProfileSyncComponentsFactoryMock(), 166 new ProfileSyncComponentsFactoryMock(),
166 profile, 167 profile,
167 signin, 168 signin,
168 ProfileSyncService::AUTO_START, 169 ProfileSyncService::AUTO_START,
169 true); 170 true);
170 } 171 }
171 }; 172 };
172 173
173 ProfileKeyedService* BuildFakeTokenService(content::BrowserContext* profile) { 174 BrowserContextKeyedService* BuildFakeTokenService(
175 content::BrowserContext* profile) {
174 return new FakeTokenService(); 176 return new FakeTokenService();
175 } 177 }
176 178
177 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { 179 TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
178 // We've never completed startup. 180 // We've never completed startup.
179 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); 181 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
180 SigninManagerFactory::GetForProfile( 182 SigninManagerFactory::GetForProfile(
181 profile_.get())->Initialize(profile_.get(), NULL); 183 profile_.get())->Initialize(profile_.get(), NULL);
182 CreateSyncService(); 184 CreateSyncService();
183 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); 185 DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 525
524 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); 526 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
525 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( 527 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
526 GaiaConstants::kSyncService, "sync_token"); 528 GaiaConstants::kSyncService, "sync_token");
527 sync_->fail_initial_download(); 529 sync_->fail_initial_download();
528 530
529 sync_->Initialize(); 531 sync_->Initialize();
530 EXPECT_FALSE(sync_->sync_initialized()); 532 EXPECT_FALSE(sync_->sync_initialized());
531 EXPECT_FALSE(sync_->GetBackendForTest()); 533 EXPECT_FALSE(sync_->GetBackendForTest());
532 } 534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698