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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 harness_.service->StopAndSuppress(); | 480 harness_.service->StopAndSuppress(); |
481 harness_.service->UnsuppressAndStart(); | 481 harness_.service->UnsuppressAndStart(); |
482 | 482 |
483 SyncBackendHostForProfileSyncTest* const backend = | 483 SyncBackendHostForProfileSyncTest* const backend = |
484 harness_.service->GetBackendForTest(); | 484 harness_.service->GetBackendForTest(); |
485 | 485 |
486 backend->EmitOnInvalidatorStateChange(syncer::INVALIDATIONS_ENABLED); | 486 backend->EmitOnInvalidatorStateChange(syncer::INVALIDATIONS_ENABLED); |
487 EXPECT_EQ(syncer::INVALIDATIONS_ENABLED, handler.GetInvalidatorState()); | 487 EXPECT_EQ(syncer::INVALIDATIONS_ENABLED, handler.GetInvalidatorState()); |
488 | 488 |
489 backend->EmitOnIncomingInvalidation(states, syncer::REMOTE_INVALIDATION); | 489 backend->EmitOnIncomingInvalidation(states); |
490 EXPECT_THAT(states, Eq(handler.GetLastInvalidationMap())); | 490 EXPECT_THAT(states, Eq(handler.GetLastInvalidationMap())); |
491 EXPECT_EQ(syncer::REMOTE_INVALIDATION, handler.GetLastInvalidationSource()); | |
492 | 491 |
493 backend->EmitOnInvalidatorStateChange(syncer::TRANSIENT_INVALIDATION_ERROR); | 492 backend->EmitOnInvalidatorStateChange(syncer::TRANSIENT_INVALIDATION_ERROR); |
494 EXPECT_EQ(syncer::TRANSIENT_INVALIDATION_ERROR, | 493 EXPECT_EQ(syncer::TRANSIENT_INVALIDATION_ERROR, |
495 handler.GetInvalidatorState()); | 494 handler.GetInvalidatorState()); |
496 | 495 |
497 harness_.service->UnregisterInvalidationHandler(&handler); | 496 harness_.service->UnregisterInvalidationHandler(&handler); |
498 } | 497 } |
499 | 498 |
500 // Thin Invalidator wrapper around ProfileSyncService. | 499 // Thin Invalidator wrapper around ProfileSyncService. |
501 class ProfileSyncServiceInvalidator : public syncer::Invalidator { | 500 class ProfileSyncServiceInvalidator : public syncer::Invalidator { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 578 |
580 void WaitForInvalidator() { | 579 void WaitForInvalidator() { |
581 // Do nothing. | 580 // Do nothing. |
582 } | 581 } |
583 | 582 |
584 void TriggerOnInvalidatorStateChange(syncer::InvalidatorState state) { | 583 void TriggerOnInvalidatorStateChange(syncer::InvalidatorState state) { |
585 harness_.service->GetBackendForTest()->EmitOnInvalidatorStateChange(state); | 584 harness_.service->GetBackendForTest()->EmitOnInvalidatorStateChange(state); |
586 } | 585 } |
587 | 586 |
588 void TriggerOnIncomingInvalidation( | 587 void TriggerOnIncomingInvalidation( |
589 const syncer::ObjectIdInvalidationMap& invalidation_map, | 588 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
590 syncer::IncomingInvalidationSource source) { | |
591 harness_.service->GetBackendForTest()->EmitOnIncomingInvalidation( | 589 harness_.service->GetBackendForTest()->EmitOnIncomingInvalidation( |
592 invalidation_map, source); | 590 invalidation_map); |
593 } | 591 } |
594 | 592 |
595 private: | 593 private: |
596 ProfileSyncServiceTestHarness harness_; | 594 ProfileSyncServiceTestHarness harness_; |
597 scoped_ptr<ProfileSyncServiceInvalidator> invalidator_; | 595 scoped_ptr<ProfileSyncServiceInvalidator> invalidator_; |
598 }; | 596 }; |
599 | 597 |
600 } // namespace browser_sync | 598 } // namespace browser_sync |
601 | 599 |
602 namespace syncer { | 600 namespace syncer { |
603 namespace { | 601 namespace { |
604 | 602 |
605 // ProfileSyncService should behave just like an invalidator. | 603 // ProfileSyncService should behave just like an invalidator. |
606 INSTANTIATE_TYPED_TEST_CASE_P( | 604 INSTANTIATE_TYPED_TEST_CASE_P( |
607 ProfileSyncServiceInvalidatorTest, InvalidatorTest, | 605 ProfileSyncServiceInvalidatorTest, InvalidatorTest, |
608 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); | 606 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); |
609 | 607 |
610 } // namespace | 608 } // namespace |
611 } // namespace syncer | 609 } // namespace syncer |
OLD | NEW |