| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "components/sync_driver/device_info_sync_service.h" | 6 #include "components/sync_driver/device_info_sync_service.h" |
| 7 #include "components/sync_driver/local_device_info_provider_mock.h" | 7 #include "components/sync_driver/local_device_info_provider_mock.h" |
| 8 #include "sync/api/sync_change.h" | 8 #include "sync/api/sync_change.h" |
| 9 #include "sync/api/sync_change_processor.h" | 9 #include "sync/api/sync_change_processor.h" |
| 10 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 10 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 using syncer::SyncErrorFactoryMock; | 27 using syncer::SyncErrorFactoryMock; |
| 28 using syncer::SyncMergeResult; | 28 using syncer::SyncMergeResult; |
| 29 | 29 |
| 30 namespace sync_driver { | 30 namespace sync_driver { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 class TestChangeProcessor : public SyncChangeProcessor { | 34 class TestChangeProcessor : public SyncChangeProcessor { |
| 35 public: | 35 public: |
| 36 TestChangeProcessor() {} | 36 TestChangeProcessor() {} |
| 37 virtual ~TestChangeProcessor() {} | 37 ~TestChangeProcessor() override {} |
| 38 | 38 |
| 39 // SyncChangeProcessor implementation. | 39 // SyncChangeProcessor implementation. |
| 40 // Store a copy of all the changes passed in so we can examine them later. | 40 // Store a copy of all the changes passed in so we can examine them later. |
| 41 virtual SyncError ProcessSyncChanges( | 41 SyncError ProcessSyncChanges(const tracked_objects::Location& from_here, |
| 42 const tracked_objects::Location& from_here, | 42 const SyncChangeList& change_list) override { |
| 43 const SyncChangeList& change_list) override { | |
| 44 change_list_ = change_list; | 43 change_list_ = change_list; |
| 45 return SyncError(); | 44 return SyncError(); |
| 46 } | 45 } |
| 47 | 46 |
| 48 // This method isn't used in these tests. | 47 // This method isn't used in these tests. |
| 49 virtual SyncDataList GetAllSyncData(ModelType type) const override { | 48 SyncDataList GetAllSyncData(ModelType type) const override { |
| 50 return SyncDataList(); | 49 return SyncDataList(); |
| 51 } | 50 } |
| 52 | 51 |
| 53 size_t change_list_size() const { return change_list_.size(); } | 52 size_t change_list_size() const { return change_list_.size(); } |
| 54 | 53 |
| 55 SyncChange::SyncChangeType change_type_at(size_t index) const { | 54 SyncChange::SyncChangeType change_type_at(size_t index) const { |
| 56 CHECK_LT(index, change_list_size()); | 55 CHECK_LT(index, change_list_size()); |
| 57 return change_list_[index].change_type(); | 56 return change_list_[index].change_type(); |
| 58 } | 57 } |
| 59 | 58 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 sync_service_.reset(new DeviceInfoSyncService(local_device_.get())); | 90 sync_service_.reset(new DeviceInfoSyncService(local_device_.get())); |
| 92 sync_processor_.reset(new TestChangeProcessor()); | 91 sync_processor_.reset(new TestChangeProcessor()); |
| 93 // Register observer | 92 // Register observer |
| 94 sync_service_->AddObserver(this); | 93 sync_service_->AddObserver(this); |
| 95 } | 94 } |
| 96 | 95 |
| 97 virtual void TearDown() override { | 96 virtual void TearDown() override { |
| 98 sync_service_->RemoveObserver(this); | 97 sync_service_->RemoveObserver(this); |
| 99 } | 98 } |
| 100 | 99 |
| 101 virtual void OnDeviceInfoChange() override { | 100 void OnDeviceInfoChange() override { num_device_info_changed_callbacks_++; } |
| 102 num_device_info_changed_callbacks_++; | |
| 103 } | |
| 104 | 101 |
| 105 scoped_ptr<SyncChangeProcessor> PassProcessor() { | 102 scoped_ptr<SyncChangeProcessor> PassProcessor() { |
| 106 return scoped_ptr<SyncChangeProcessor>( | 103 return scoped_ptr<SyncChangeProcessor>( |
| 107 new SyncChangeProcessorWrapperForTest(sync_processor_.get())); | 104 new SyncChangeProcessorWrapperForTest(sync_processor_.get())); |
| 108 } | 105 } |
| 109 | 106 |
| 110 scoped_ptr<SyncErrorFactory> CreateAndPassSyncErrorFactory() { | 107 scoped_ptr<SyncErrorFactory> CreateAndPassSyncErrorFactory() { |
| 111 return scoped_ptr<SyncErrorFactory>(new SyncErrorFactoryMock()); | 108 return scoped_ptr<SyncErrorFactory>(new SyncErrorFactoryMock()); |
| 112 } | 109 } |
| 113 | 110 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 EXPECT_EQ("client_1", sync_processor_->client_name_at(0)); | 544 EXPECT_EQ("client_1", sync_processor_->client_name_at(0)); |
| 548 | 545 |
| 549 backup_time = syncer::ProtoTimeToTime( | 546 backup_time = syncer::ProtoTimeToTime( |
| 550 sync_processor_->device_info_at(0).backup_timestamp()); | 547 sync_processor_->device_info_at(0).backup_timestamp()); |
| 551 EXPECT_EQ(6000, backup_time.ToTimeT()); | 548 EXPECT_EQ(6000, backup_time.ToTimeT()); |
| 552 } | 549 } |
| 553 | 550 |
| 554 } // namespace | 551 } // namespace |
| 555 | 552 |
| 556 } // namespace sync_driver | 553 } // namespace sync_driver |
| OLD | NEW |