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" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 TEST_F(ProfileSyncServiceTest, InitialState) { | 173 TEST_F(ProfileSyncServiceTest, InitialState) { |
174 SigninManager* signin = | 174 SigninManager* signin = |
175 SigninManagerFactory::GetForProfile(harness_.profile.get()); | 175 SigninManagerFactory::GetForProfile(harness_.profile.get()); |
176 harness_.service.reset(new TestProfileSyncService( | 176 harness_.service.reset(new TestProfileSyncService( |
177 new ProfileSyncComponentsFactoryMock(), | 177 new ProfileSyncComponentsFactoryMock(), |
178 harness_.profile.get(), | 178 harness_.profile.get(), |
179 signin, | 179 signin, |
180 ProfileSyncService::MANUAL_START, | 180 ProfileSyncService::MANUAL_START, |
181 true, | 181 true, |
182 base::Closure())); | 182 base::Closure())); |
| 183 harness_.service->Initialize(); |
183 EXPECT_TRUE( | 184 EXPECT_TRUE( |
184 harness_.service->sync_service_url().spec() == | 185 harness_.service->sync_service_url().spec() == |
185 ProfileSyncService::kSyncServerUrl || | 186 ProfileSyncService::kSyncServerUrl || |
186 harness_.service->sync_service_url().spec() == | 187 harness_.service->sync_service_url().spec() == |
187 ProfileSyncService::kDevServerUrl); | 188 ProfileSyncService::kDevServerUrl); |
188 } | 189 } |
189 | 190 |
190 TEST_F(ProfileSyncServiceTest, DisabledByPolicy) { | 191 TEST_F(ProfileSyncServiceTest, DisabledByPolicy) { |
191 harness_.profile->GetTestingPrefService()->SetManagedPref( | 192 harness_.profile->GetTestingPrefService()->SetManagedPref( |
192 prefs::kSyncManaged, | 193 prefs::kSyncManaged, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 backend->EmitOnInvalidatorStateChange(syncer::INVALIDATIONS_ENABLED); | 424 backend->EmitOnInvalidatorStateChange(syncer::INVALIDATIONS_ENABLED); |
424 EXPECT_EQ(syncer::INVALIDATIONS_ENABLED, handler.GetInvalidatorState()); | 425 EXPECT_EQ(syncer::INVALIDATIONS_ENABLED, handler.GetInvalidatorState()); |
425 | 426 |
426 backend->EmitOnIncomingInvalidation(states, syncer::REMOTE_INVALIDATION); | 427 backend->EmitOnIncomingInvalidation(states, syncer::REMOTE_INVALIDATION); |
427 EXPECT_THAT(states, Eq(handler.GetLastInvalidationMap())); | 428 EXPECT_THAT(states, Eq(handler.GetLastInvalidationMap())); |
428 EXPECT_EQ(syncer::REMOTE_INVALIDATION, handler.GetLastInvalidationSource()); | 429 EXPECT_EQ(syncer::REMOTE_INVALIDATION, handler.GetLastInvalidationSource()); |
429 | 430 |
430 backend->EmitOnInvalidatorStateChange(syncer::TRANSIENT_INVALIDATION_ERROR); | 431 backend->EmitOnInvalidatorStateChange(syncer::TRANSIENT_INVALIDATION_ERROR); |
431 EXPECT_EQ(syncer::TRANSIENT_INVALIDATION_ERROR, | 432 EXPECT_EQ(syncer::TRANSIENT_INVALIDATION_ERROR, |
432 handler.GetInvalidatorState()); | 433 handler.GetInvalidatorState()); |
| 434 |
| 435 harness_.service->UnregisterInvalidationHandler(&handler); |
433 } | 436 } |
434 | 437 |
435 // Thin Invalidator wrapper around ProfileSyncService. | 438 // Thin Invalidator wrapper around ProfileSyncService. |
436 class ProfileSyncServiceInvalidator : public syncer::Invalidator { | 439 class ProfileSyncServiceInvalidator : public syncer::Invalidator { |
437 public: | 440 public: |
438 explicit ProfileSyncServiceInvalidator(ProfileSyncService* service) | 441 explicit ProfileSyncServiceInvalidator(ProfileSyncService* service) |
439 : service_(service) {} | 442 : service_(service) {} |
440 | 443 |
441 virtual ~ProfileSyncServiceInvalidator() {} | 444 virtual ~ProfileSyncServiceInvalidator() {} |
442 | 445 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 namespace syncer { | 548 namespace syncer { |
546 namespace { | 549 namespace { |
547 | 550 |
548 // ProfileSyncService should behave just like an invalidator. | 551 // ProfileSyncService should behave just like an invalidator. |
549 INSTANTIATE_TYPED_TEST_CASE_P( | 552 INSTANTIATE_TYPED_TEST_CASE_P( |
550 ProfileSyncServiceInvalidatorTest, InvalidatorTest, | 553 ProfileSyncServiceInvalidatorTest, InvalidatorTest, |
551 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); | 554 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); |
552 | 555 |
553 } // namespace | 556 } // namespace |
554 } // namespace syncer | 557 } // namespace syncer |
OLD | NEW |