| 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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/signin/signin_manager.h" | 11 #include "chrome/browser/signin/signin_manager.h" |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" | 12 #include "chrome/browser/signin/signin_manager_factory.h" |
| 13 #include "chrome/browser/signin/token_service.h" | 13 #include "chrome/browser/signin/token_service.h" |
| 14 #include "chrome/browser/signin/token_service_factory.h" | 14 #include "chrome/browser/signin/token_service_factory.h" |
| 15 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" | 15 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" |
| 16 #include "chrome/browser/sync/glue/data_type_controller.h" | 16 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 17 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 17 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
| 18 #include "chrome/browser/sync/test_profile_sync_service.h" | 18 #include "chrome/browser/sync/test_profile_sync_service.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
| 20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/test/base/testing_pref_service_syncable.h" | 22 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 23 #include "content/public/test/test_browser_thread.h" | 24 #include "content/public/test/test_browser_thread.h" |
| 24 #include "google/cacheinvalidation/include/types.h" | 25 #include "google/cacheinvalidation/include/types.h" |
| 25 #include "google_apis/gaia/gaia_constants.h" | 26 #include "google_apis/gaia/gaia_constants.h" |
| 26 #include "sync/js/js_arg_list.h" | 27 #include "sync/js/js_arg_list.h" |
| 27 #include "sync/js/js_event_details.h" | 28 #include "sync/js/js_event_details.h" |
| 28 #include "sync/js/js_test_util.h" | 29 #include "sync/js/js_test_util.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 harness_.service.reset(new TestProfileSyncService( | 216 harness_.service.reset(new TestProfileSyncService( |
| 216 new ProfileSyncComponentsFactoryMock(), | 217 new ProfileSyncComponentsFactoryMock(), |
| 217 harness_.profile.get(), | 218 harness_.profile.get(), |
| 218 signin, | 219 signin, |
| 219 ProfileSyncService::MANUAL_START, | 220 ProfileSyncService::MANUAL_START, |
| 220 true)); | 221 true)); |
| 221 harness_.service->Initialize(); | 222 harness_.service->Initialize(); |
| 222 EXPECT_TRUE(harness_.service->IsManaged()); | 223 EXPECT_TRUE(harness_.service->IsManaged()); |
| 223 } | 224 } |
| 224 | 225 |
| 226 TEST_F(ProfileSyncServiceTest, DisabledByAdmin) { |
| 227 harness_.profile->GetTestingPrefService()->SetUserPref( |
| 228 prefs::kSyncDisabledByAdmin, |
| 229 Value::CreateBooleanValue(true)); |
| 230 SigninManagerBase* signin = |
| 231 SigninManagerFactory::GetForProfile(harness_.profile.get()); |
| 232 harness_.service.reset(new TestProfileSyncService( |
| 233 new ProfileSyncComponentsFactoryMock(), |
| 234 harness_.profile.get(), |
| 235 signin, |
| 236 ProfileSyncService::MANUAL_START, |
| 237 true)); |
| 238 harness_.service->Initialize(); |
| 239 EXPECT_TRUE(harness_.service->IsManaged()); |
| 240 |
| 241 content::Source<Profile> stub_source(NULL); |
| 242 content::NotificationDetails stub_details; |
| 243 |
| 244 harness_.service->Observe(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
| 245 stub_source, stub_details); |
| 246 EXPECT_FALSE(harness_.profile->GetTestingPrefService()->GetBoolean( |
| 247 prefs::kSyncDisabledByAdmin)); |
| 248 |
| 249 harness_.service->Shutdown(); |
| 250 |
| 251 harness_.service.reset(new TestProfileSyncService( |
| 252 new ProfileSyncComponentsFactoryMock(), |
| 253 harness_.profile.get(), |
| 254 signin, |
| 255 ProfileSyncService::MANUAL_START, |
| 256 true)); |
| 257 harness_.service->Initialize(); |
| 258 EXPECT_FALSE(harness_.service->IsManaged()); |
| 259 harness_.service->Shutdown(); |
| 260 harness_.service.reset(); |
| 261 } |
| 262 |
| 225 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { | 263 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { |
| 226 SigninManagerBase* signin = | 264 SigninManagerBase* signin = |
| 227 SigninManagerFactory::GetForProfile(harness_.profile.get()); | 265 SigninManagerFactory::GetForProfile(harness_.profile.get()); |
| 228 signin->SetAuthenticatedUsername("test"); | 266 signin->SetAuthenticatedUsername("test"); |
| 229 ProfileSyncComponentsFactoryMock* factory = | 267 ProfileSyncComponentsFactoryMock* factory = |
| 230 new ProfileSyncComponentsFactoryMock(); | 268 new ProfileSyncComponentsFactoryMock(); |
| 231 harness_.service.reset(new TestProfileSyncService( | 269 harness_.service.reset(new TestProfileSyncService( |
| 232 factory, | 270 factory, |
| 233 harness_.profile.get(), | 271 harness_.profile.get(), |
| 234 signin, | 272 signin, |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 namespace syncer { | 661 namespace syncer { |
| 624 namespace { | 662 namespace { |
| 625 | 663 |
| 626 // ProfileSyncService should behave just like an invalidator. | 664 // ProfileSyncService should behave just like an invalidator. |
| 627 INSTANTIATE_TYPED_TEST_CASE_P( | 665 INSTANTIATE_TYPED_TEST_CASE_P( |
| 628 ProfileSyncServiceInvalidatorTest, InvalidatorTest, | 666 ProfileSyncServiceInvalidatorTest, InvalidatorTest, |
| 629 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); | 667 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); |
| 630 | 668 |
| 631 } // namespace | 669 } // namespace |
| 632 } // namespace syncer | 670 } // namespace syncer |
| OLD | NEW |