OLD | NEW |
---|---|
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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 11 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
12 #include "chrome/browser/signin/signin_manager.h" | 12 #include "chrome/browser/signin/signin_manager.h" |
13 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
14 #include "chrome/browser/signin/token_service.h" | 14 #include "chrome/browser/signin/token_service.h" |
15 #include "chrome/browser/signin/token_service_factory.h" | 15 #include "chrome/browser/signin/token_service_factory.h" |
16 #include "chrome/browser/sync/fake_oauth2_token_service.h" | 16 #include "chrome/browser/sync/fake_oauth2_token_service.h" |
17 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" | 17 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" |
18 #include "chrome/browser/sync/glue/data_type_controller.h" | 18 #include "chrome/browser/sync/glue/data_type_controller.h" |
19 #include "chrome/browser/sync/glue/sync_backend_host_mock.h" | |
19 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 20 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
20 #include "chrome/browser/sync/test_profile_sync_service.h" | 21 #include "chrome/browser/sync/test_profile_sync_service.h" |
21 #include "chrome/common/chrome_version_info.h" | 22 #include "chrome/common/chrome_version_info.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/testing_pref_service_syncable.h" | 24 #include "chrome/test/base/testing_pref_service_syncable.h" |
24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
25 #include "content/public/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
26 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
27 #include "google/cacheinvalidation/include/types.h" | 28 #include "google/cacheinvalidation/include/types.h" |
28 #include "google_apis/gaia/gaia_constants.h" | 29 #include "google_apis/gaia/gaia_constants.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
46 using testing::Mock; | 47 using testing::Mock; |
47 using testing::Return; | 48 using testing::Return; |
48 using testing::StrictMock; | 49 using testing::StrictMock; |
49 | 50 |
50 void SignalDone(base::WaitableEvent* done) { | 51 void SignalDone(base::WaitableEvent* done) { |
51 done->Signal(); | 52 done->Signal(); |
52 } | 53 } |
53 | 54 |
54 class ProfileSyncServiceTest : public testing::Test { | 55 class ProfileSyncServiceTest : public testing::Test { |
55 protected: | 56 protected: |
56 ProfileSyncServiceTest() | 57 ProfileSyncServiceTest() |
Nicolas Zea
2013/11/13 21:06:45
nit: this should have a virtual destructor btw
| |
57 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | | 58 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | |
58 content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 59 content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
59 content::TestBrowserThreadBundle::REAL_IO_THREAD) { | 60 content::TestBrowserThreadBundle::REAL_IO_THREAD) { |
60 } | 61 } |
61 | 62 |
62 virtual void SetUp() OVERRIDE { | 63 virtual void SetUp() OVERRIDE { |
63 TestingProfile::Builder builder; | 64 TestingProfile::Builder builder; |
64 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | 65 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
65 FakeOAuth2TokenService::BuildTokenService); | 66 FakeOAuth2TokenService::BuildTokenService); |
66 profile_ = builder.Build().Pass(); | 67 profile_ = builder.Build().Pass(); |
67 invalidation::InvalidationServiceFactory::GetInstance()-> | 68 invalidation::InvalidationServiceFactory::GetInstance()-> |
68 SetBuildOnlyFakeInvalidatorsForTest(true); | 69 SetBuildOnlyFakeInvalidatorsForTest(true); |
69 } | 70 } |
70 | 71 |
71 virtual void TearDown() OVERRIDE { | 72 virtual void TearDown() OVERRIDE { |
72 // Kill the service before the profile. | 73 // Kill the service before the profile. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 : service_(service), first_setup_in_progress_(false) {} | 166 : service_(service), first_setup_in_progress_(false) {} |
166 virtual void OnStateChanged() OVERRIDE { | 167 virtual void OnStateChanged() OVERRIDE { |
167 first_setup_in_progress_ = service_->FirstSetupInProgress(); | 168 first_setup_in_progress_ = service_->FirstSetupInProgress(); |
168 } | 169 } |
169 bool first_setup_in_progress() const { return first_setup_in_progress_; } | 170 bool first_setup_in_progress() const { return first_setup_in_progress_; } |
170 private: | 171 private: |
171 ProfileSyncService* service_; | 172 ProfileSyncService* service_; |
172 bool first_setup_in_progress_; | 173 bool first_setup_in_progress_; |
173 }; | 174 }; |
174 | 175 |
175 TEST_F(ProfileSyncServiceTest, InitialState) { | 176 // A variant of the SyncBackendHostMock that won't automatically |
176 SigninManagerBase* signin = | 177 // call back when asked to initialized. Allows us to test things |
177 SigninManagerFactory::GetForProfile(profile_.get()); | 178 // that could happen while backend init is in progress. |
178 ProfileOAuth2TokenService* oauth2_token_service = | 179 class SyncBackendHostNoReturn : public SyncBackendHostMock { |
179 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 180 virtual void Initialize( |
180 service_.reset(new TestProfileSyncService( | 181 SyncFrontend* frontend, |
181 new ProfileSyncComponentsFactoryMock(), | 182 scoped_ptr<base::Thread> sync_thread, |
182 profile_.get(), | 183 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
183 signin, | 184 const GURL& service_url, |
184 oauth2_token_service, | 185 const syncer::SyncCredentials& credentials, |
185 ProfileSyncService::MANUAL_START, | 186 bool delete_sync_data_folder, |
186 true)); | 187 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
187 service_->Initialize(); | 188 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler, |
188 EXPECT_TRUE( | 189 syncer::ReportUnrecoverableErrorFunction |
189 service_->sync_service_url().spec() == | 190 report_unrecoverable_error_function) OVERRIDE {} |
190 ProfileSyncService::kSyncServerUrl || | 191 }; |
191 service_->sync_service_url().spec() == | 192 |
192 ProfileSyncService::kDevServerUrl); | 193 ACTION(ReturnNewSyncBackendHostMock) { |
193 } | 194 return new browser_sync::SyncBackendHostMock(); |
194 | 195 } |
195 // Tests that the sync service doesn't forget to notify observers about | 196 |
196 // setup state. | 197 ACTION(ReturnNewSyncBackendHostNoReturn) { |
197 TEST(ProfileSyncServiceTestBasic, SetupInProgress) { | 198 return new browser_sync::SyncBackendHostNoReturn(); |
198 ProfileSyncService service( | 199 } |
199 NULL, NULL, NULL, NULL, ProfileSyncService::MANUAL_START); | 200 |
200 TestProfileSyncServiceObserver observer(&service); | 201 class ProfileSyncServiceSimpleTest : public ::testing::Test { |
Nicolas Zea
2013/11/13 21:06:45
nit: Comment about how this differs?
rlarocque
2013/11/13 22:28:25
Added a comment that describes the code.
The plan
| |
201 service.AddObserver(&observer); | 202 protected: |
202 service.SetSetupInProgress(true); | 203 ProfileSyncServiceSimpleTest() |
204 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | | |
205 content::TestBrowserThreadBundle::REAL_FILE_THREAD | | |
206 content::TestBrowserThreadBundle::REAL_IO_THREAD) {} | |
207 virtual ~ProfileSyncServiceSimpleTest() {} | |
208 | |
209 virtual void SetUp() OVERRIDE { | |
210 TestingProfile::Builder builder; | |
211 | |
212 builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), | |
213 FakeOAuth2TokenService::BuildTokenService); | |
214 invalidation::InvalidationServiceFactory::GetInstance()-> | |
215 SetBuildOnlyFakeInvalidatorsForTest(true); | |
216 | |
217 profile_ = builder.Build().Pass(); | |
218 } | |
219 | |
220 virtual void TearDown() OVERRIDE { | |
221 // Kill the service before the profile. | |
222 if (service_) | |
223 service_->Shutdown(); | |
224 | |
225 service_.reset(); | |
226 profile_.reset(); | |
227 | |
228 // Pump messages posted by the sync thread (which may end up | |
229 // posting on the IO thread). | |
230 base::RunLoop().RunUntilIdle(); | |
231 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); | |
232 base::RunLoop().RunUntilIdle(); | |
233 } | |
234 | |
235 void IssueTestTokens() { | |
236 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()) | |
Nicolas Zea
2013/11/13 21:06:45
extract this into a standalone function both class
rlarocque
2013/11/13 22:28:25
Since we plan to remove the ProfileSyncServiceTest
| |
237 ->UpdateCredentials("test", "oauth2_login_token"); | |
238 } | |
239 | |
240 void CreateService(ProfileSyncService::StartBehavior behavior) { | |
241 SigninManagerBase* signin = | |
242 SigninManagerFactory::GetForProfile(profile_.get()); | |
243 signin->SetAuthenticatedUsername("test"); | |
244 ProfileOAuth2TokenService* oauth2_token_service = | |
245 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | |
246 components_factory_ = new StrictMock<ProfileSyncComponentsFactoryMock>(); | |
247 service_.reset(new ProfileSyncService( | |
248 components_factory_, | |
249 profile_.get(), | |
250 signin, | |
251 oauth2_token_service, | |
252 behavior)); | |
253 } | |
254 | |
255 void ShutdownAndDeleteService() { | |
256 if (service_) | |
257 service_->Shutdown(); | |
258 service_.reset(); | |
259 } | |
260 | |
261 void Initialize() { | |
262 service_->Initialize(); | |
263 } | |
264 | |
265 void ExpectDataTypeManagerCreation() { | |
266 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _, _)). | |
267 WillOnce(ReturnNewDataTypeManager()); | |
268 } | |
269 | |
270 void ExpectSyncBackendHostCreation() { | |
271 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _)). | |
272 WillOnce(ReturnNewSyncBackendHostMock()); | |
273 } | |
274 | |
275 void PrepareDelayedInitSyncBackendHost() { | |
276 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _)). | |
277 WillOnce(ReturnNewSyncBackendHostNoReturn()); | |
278 } | |
279 | |
280 TestingProfile* profile() { | |
281 return profile_.get(); | |
282 } | |
283 | |
284 ProfileSyncService* service() { | |
285 return service_.get(); | |
286 } | |
287 | |
288 ProfileSyncComponentsFactoryMock* components_factory() { | |
289 return components_factory_; | |
290 } | |
291 | |
292 private: | |
293 scoped_ptr<TestingProfile> profile_; | |
294 scoped_ptr<ProfileSyncService> service_; | |
295 | |
296 // Pointer to the components factory. Not owned. May be null. | |
297 ProfileSyncComponentsFactoryMock* components_factory_; | |
298 | |
299 content::TestBrowserThreadBundle thread_bundle_; | |
300 }; | |
301 | |
302 // Verify that the server URLs are sane. | |
303 TEST_F(ProfileSyncServiceSimpleTest, InitialState) { | |
304 CreateService(ProfileSyncService::AUTO_START); | |
305 Initialize(); | |
306 const std::string& url = service()->sync_service_url().spec(); | |
307 EXPECT_TRUE(url == ProfileSyncService::kSyncServerUrl || | |
308 url == ProfileSyncService::kDevServerUrl); | |
309 } | |
310 | |
311 // Verify that the SetSetupInProgress function call updates state | |
312 // and notifies observers. | |
313 TEST_F(ProfileSyncServiceSimpleTest, SetupInProgress) { | |
314 CreateService(ProfileSyncService::MANUAL_START); | |
315 Initialize(); | |
316 | |
317 TestProfileSyncServiceObserver observer(service()); | |
318 service()->AddObserver(&observer); | |
319 | |
320 service()->SetSetupInProgress(true); | |
203 EXPECT_TRUE(observer.first_setup_in_progress()); | 321 EXPECT_TRUE(observer.first_setup_in_progress()); |
204 service.SetSetupInProgress(false); | 322 service()->SetSetupInProgress(false); |
205 EXPECT_FALSE(observer.first_setup_in_progress()); | 323 EXPECT_FALSE(observer.first_setup_in_progress()); |
206 service.RemoveObserver(&observer); | 324 |
207 } | 325 service()->RemoveObserver(&observer); |
208 | 326 } |
209 TEST_F(ProfileSyncServiceTest, DisabledByPolicy) { | 327 |
210 profile_->GetTestingPrefService()->SetManagedPref( | 328 // Verify that disable by enterprise policy works. |
329 TEST_F(ProfileSyncServiceSimpleTest, DisabledByPolicy) { | |
330 profile()->GetTestingPrefService()->SetManagedPref( | |
211 prefs::kSyncManaged, | 331 prefs::kSyncManaged, |
212 Value::CreateBooleanValue(true)); | 332 Value::CreateBooleanValue(true)); |
213 SigninManagerBase* signin = | 333 IssueTestTokens(); |
214 SigninManagerFactory::GetForProfile(profile_.get()); | 334 CreateService(ProfileSyncService::AUTO_START); |
215 ProfileOAuth2TokenService* oauth2_token_service = | 335 Initialize(); |
216 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 336 EXPECT_TRUE(service()->IsManaged()); |
217 service_.reset(new TestProfileSyncService( | 337 EXPECT_FALSE(service()->sync_initialized()); |
218 new ProfileSyncComponentsFactoryMock(), | 338 } |
219 profile_.get(), | 339 |
220 signin, | 340 // Verify a successful init. |
221 oauth2_token_service, | 341 // |
222 ProfileSyncService::MANUAL_START, | 342 // This test is complementary to the one above. The DisabledByPolicy test could |
223 true)); | 343 // return a false positive if there was something else (eg. lack of auth tokens) |
224 service_->Initialize(); | 344 // that prevents sync startup. This test ensures that not setting the |
225 EXPECT_TRUE(service_->IsManaged()); | 345 // enterprise policy disable flag results in a successful init. |
226 } | 346 TEST_F(ProfileSyncServiceSimpleTest, NotDisabledByPolicy) { |
Nicolas Zea
2013/11/13 21:06:45
Isn't this just a normal init test (which I agree
rlarocque
2013/11/13 22:28:25
Yeah, it's pretty much a normal init test. I adde
| |
227 | 347 profile()->GetTestingPrefService()->SetManagedPref( |
228 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { | 348 prefs::kSyncManaged, |
229 SigninManagerBase* signin = | 349 Value::CreateBooleanValue(false)); |
230 SigninManagerFactory::GetForProfile(profile_.get()); | 350 IssueTestTokens(); |
231 signin->SetAuthenticatedUsername("test"); | 351 CreateService(ProfileSyncService::AUTO_START); |
232 ProfileOAuth2TokenService* oauth2_token_service = | 352 ExpectDataTypeManagerCreation(); |
233 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 353 ExpectSyncBackendHostCreation(); |
234 ProfileSyncComponentsFactoryMock* factory = | 354 Initialize(); |
235 new ProfileSyncComponentsFactoryMock(); | 355 EXPECT_FALSE(service()->IsManaged()); |
236 service_.reset(new TestProfileSyncService( | 356 EXPECT_TRUE(service()->sync_initialized()); |
237 factory, | 357 } |
238 profile_.get(), | 358 |
239 signin, | 359 // Exercies the ProfileSyncService's code paths related to getting shut down |
240 oauth2_token_service, | 360 // before the backend initialize call returns. |
241 ProfileSyncService::AUTO_START, | 361 TEST_F(ProfileSyncServiceSimpleTest, AbortedByShutdown) { |
242 true)); | 362 CreateService(ProfileSyncService::AUTO_START); |
243 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)).Times(0); | 363 PrepareDelayedInitSyncBackendHost(); |
244 EXPECT_CALL(*factory, CreateBookmarkSyncComponents(_, _)). | 364 |
245 Times(0); | 365 IssueTestTokens(); |
246 service_->RegisterDataTypeController( | 366 Initialize(); |
247 new BookmarkDataTypeController(service_->factory(), | 367 EXPECT_FALSE(service()->sync_initialized()); |
248 profile_.get(), | 368 |
249 service_.get())); | 369 ShutdownAndDeleteService(); |
250 | 370 } |
251 service_->Initialize(); | 371 |
252 service_->Shutdown(); | 372 TEST_F(ProfileSyncServiceSimpleTest, DisableAndEnableSyncTemporarily) { |
253 service_.reset(); | 373 CreateService(ProfileSyncService::AUTO_START); |
254 } | 374 IssueTestTokens(); |
255 | 375 ExpectDataTypeManagerCreation(); |
256 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { | 376 ExpectSyncBackendHostCreation(); |
257 SigninManagerBase* signin = | 377 Initialize(); |
258 SigninManagerFactory::GetForProfile(profile_.get()); | 378 |
259 signin->SetAuthenticatedUsername("test"); | 379 EXPECT_TRUE(service()->sync_initialized()); |
260 ProfileOAuth2TokenService* oauth2_token_service = | 380 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
261 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 381 |
262 ProfileSyncComponentsFactoryMock* factory = | 382 testing::Mock::VerifyAndClearExpectations(components_factory()); |
263 new ProfileSyncComponentsFactoryMock(); | 383 |
264 service_.reset(new TestProfileSyncService( | 384 service()->StopAndSuppress(); |
265 factory, | 385 EXPECT_FALSE(service()->sync_initialized()); |
266 profile_.get(), | 386 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
267 signin, | 387 |
268 oauth2_token_service, | 388 ExpectDataTypeManagerCreation(); |
269 ProfileSyncService::AUTO_START, | 389 ExpectSyncBackendHostCreation(); |
Nicolas Zea
2013/11/13 21:06:45
test that a suppressed start doesn't initialize be
rlarocque
2013/11/13 22:28:25
I don't follow. Are you suggesting there should b
Nicolas Zea
2013/11/13 22:37:20
More assertions. I.e, before you call UnsupressAnd
| |
270 true)); | 390 |
271 // Register the bookmark data type. | 391 service()->UnsuppressAndStart(); |
272 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)). | 392 EXPECT_TRUE(service()->sync_initialized()); |
273 WillRepeatedly(ReturnNewDataTypeManager()); | |
274 | |
275 IssueTestTokens(); | |
276 | |
277 service_->Initialize(); | |
278 EXPECT_TRUE(service_->sync_initialized()); | |
279 EXPECT_TRUE(service_->GetBackendForTest() != NULL); | |
280 EXPECT_FALSE( | 393 EXPECT_FALSE( |
281 profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | 394 profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
282 | |
283 service_->StopAndSuppress(); | |
284 EXPECT_FALSE(service_->sync_initialized()); | |
285 EXPECT_TRUE( | |
286 profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | |
287 | |
288 service_->UnsuppressAndStart(); | |
289 EXPECT_TRUE(service_->sync_initialized()); | |
290 EXPECT_FALSE( | |
291 profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | |
292 } | 395 } |
293 | 396 |
294 // Certain ProfileSyncService tests don't apply to Chrome OS, for example | 397 // Certain ProfileSyncService tests don't apply to Chrome OS, for example |
295 // things that deal with concepts like "signing out" and policy. | 398 // things that deal with concepts like "signing out" and policy. |
296 #if !defined (OS_CHROMEOS) | 399 #if !defined (OS_CHROMEOS) |
297 | 400 |
298 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { | 401 TEST_F(ProfileSyncServiceSimpleTest, EnableSyncAndSignOut) { |
299 SigninManager* signin = | 402 CreateService(ProfileSyncService::AUTO_START); |
300 SigninManagerFactory::GetForProfile(profile_.get()); | 403 ExpectDataTypeManagerCreation(); |
301 signin->SetAuthenticatedUsername("test"); | 404 ExpectSyncBackendHostCreation(); |
302 ProfileOAuth2TokenService* oauth2_token_service = | 405 IssueTestTokens(); |
303 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get()); | 406 Initialize(); |
304 ProfileSyncComponentsFactoryMock* factory = | 407 |
305 new ProfileSyncComponentsFactoryMock(); | 408 EXPECT_TRUE(service()->sync_initialized()); |
306 service_.reset(new TestProfileSyncService( | 409 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
307 factory, | 410 |
308 profile_.get(), | 411 SigninManagerFactory::GetForProfile(profile())->SignOut(); |
309 signin, | 412 EXPECT_FALSE(service()->sync_initialized()); |
310 oauth2_token_service, | |
311 ProfileSyncService::AUTO_START, | |
312 true)); | |
313 // Register the bookmark data type. | |
314 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _, _)). | |
315 WillRepeatedly(ReturnNewDataTypeManager()); | |
316 | |
317 IssueTestTokens(); | |
318 | |
319 service_->Initialize(); | |
320 EXPECT_TRUE(service_->sync_initialized()); | |
321 EXPECT_TRUE(service_->GetBackendForTest() != NULL); | |
322 EXPECT_FALSE( | |
323 profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | |
324 | |
325 signin->SignOut(); | |
326 EXPECT_FALSE(service_->sync_initialized()); | |
327 } | 413 } |
328 | 414 |
329 #endif // !defined(OS_CHROMEOS) | 415 #endif // !defined(OS_CHROMEOS) |
330 | 416 |
331 TEST_F(ProfileSyncServiceTest, JsControllerHandlersBasic) { | 417 TEST_F(ProfileSyncServiceTest, JsControllerHandlersBasic) { |
332 StartSyncService(); | 418 StartSyncService(); |
333 EXPECT_TRUE(service_->sync_initialized()); | 419 EXPECT_TRUE(service_->sync_initialized()); |
334 EXPECT_TRUE(service_->GetBackendForTest() != NULL); | 420 EXPECT_TRUE(service_->GetBackendForTest() != NULL); |
335 | 421 |
336 base::WeakPtr<syncer::JsController> js_controller = | 422 base::WeakPtr<syncer::JsController> js_controller = |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 EXPECT_TRUE(token_status.next_token_request_time.is_null()); | 600 EXPECT_TRUE(token_status.next_token_request_time.is_null()); |
515 | 601 |
516 // Simulate successful connection. | 602 // Simulate successful connection. |
517 service_->OnConnectionStatusChange(syncer::CONNECTION_OK); | 603 service_->OnConnectionStatusChange(syncer::CONNECTION_OK); |
518 token_status = service_->GetSyncTokenStatus(); | 604 token_status = service_->GetSyncTokenStatus(); |
519 EXPECT_EQ(syncer::CONNECTION_OK, token_status.connection_status); | 605 EXPECT_EQ(syncer::CONNECTION_OK, token_status.connection_status); |
520 } | 606 } |
521 | 607 |
522 } // namespace | 608 } // namespace |
523 } // namespace browser_sync | 609 } // namespace browser_sync |
OLD | NEW |