| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 class TestChangeProcessor : public SyncChangeProcessor { | 34 class TestChangeProcessor : public SyncChangeProcessor { |
| 35 public: | 35 public: |
| 36 TestChangeProcessor() {} | 36 TestChangeProcessor() {} |
| 37 virtual ~TestChangeProcessor() {} | 37 virtual ~TestChangeProcessor() {} |
| 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 virtual SyncError ProcessSyncChanges( |
| 42 const tracked_objects::Location& from_here, | 42 const tracked_objects::Location& from_here, |
| 43 const SyncChangeList& change_list) OVERRIDE { | 43 const SyncChangeList& change_list) override { |
| 44 change_list_ = change_list; | 44 change_list_ = change_list; |
| 45 return SyncError(); | 45 return SyncError(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // This method isn't used in these tests. | 48 // This method isn't used in these tests. |
| 49 virtual SyncDataList GetAllSyncData(ModelType type) const OVERRIDE { | 49 virtual SyncDataList GetAllSyncData(ModelType type) const override { |
| 50 return SyncDataList(); | 50 return SyncDataList(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 size_t change_list_size() const { return change_list_.size(); } | 53 size_t change_list_size() const { return change_list_.size(); } |
| 54 | 54 |
| 55 SyncChange::SyncChangeType change_type_at(size_t index) const { | 55 SyncChange::SyncChangeType change_type_at(size_t index) const { |
| 56 CHECK_LT(index, change_list_size()); | 56 CHECK_LT(index, change_list_size()); |
| 57 return change_list_[index].change_type(); | 57 return change_list_[index].change_type(); |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 private: | 73 private: |
| 74 SyncChangeList change_list_; | 74 SyncChangeList change_list_; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 class DeviceInfoSyncServiceTest : public testing::Test, | 77 class DeviceInfoSyncServiceTest : public testing::Test, |
| 78 public DeviceInfoTracker::Observer { | 78 public DeviceInfoTracker::Observer { |
| 79 public: | 79 public: |
| 80 DeviceInfoSyncServiceTest() : num_device_info_changed_callbacks_(0) {} | 80 DeviceInfoSyncServiceTest() : num_device_info_changed_callbacks_(0) {} |
| 81 virtual ~DeviceInfoSyncServiceTest() {} | 81 virtual ~DeviceInfoSyncServiceTest() {} |
| 82 | 82 |
| 83 virtual void SetUp() OVERRIDE { | 83 virtual void SetUp() override { |
| 84 local_device_.reset(new LocalDeviceInfoProviderMock( | 84 local_device_.reset(new LocalDeviceInfoProviderMock( |
| 85 "guid_1", | 85 "guid_1", |
| 86 "client_1", | 86 "client_1", |
| 87 "Chromium 10k", | 87 "Chromium 10k", |
| 88 "Chrome 10k", | 88 "Chrome 10k", |
| 89 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, | 89 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, |
| 90 "device_id")); | 90 "device_id")); |
| 91 sync_service_.reset(new DeviceInfoSyncService(local_device_.get())); | 91 sync_service_.reset(new DeviceInfoSyncService(local_device_.get())); |
| 92 sync_processor_.reset(new TestChangeProcessor()); | 92 sync_processor_.reset(new TestChangeProcessor()); |
| 93 // Register observer | 93 // Register observer |
| 94 sync_service_->AddObserver(this); | 94 sync_service_->AddObserver(this); |
| 95 } | 95 } |
| 96 | 96 |
| 97 virtual void TearDown() OVERRIDE { | 97 virtual void TearDown() override { |
| 98 sync_service_->RemoveObserver(this); | 98 sync_service_->RemoveObserver(this); |
| 99 } | 99 } |
| 100 | 100 |
| 101 virtual void OnDeviceInfoChange() OVERRIDE { | 101 virtual void OnDeviceInfoChange() override { |
| 102 num_device_info_changed_callbacks_++; | 102 num_device_info_changed_callbacks_++; |
| 103 } | 103 } |
| 104 | 104 |
| 105 scoped_ptr<SyncChangeProcessor> PassProcessor() { | 105 scoped_ptr<SyncChangeProcessor> PassProcessor() { |
| 106 return scoped_ptr<SyncChangeProcessor>( | 106 return scoped_ptr<SyncChangeProcessor>( |
| 107 new SyncChangeProcessorWrapperForTest(sync_processor_.get())); | 107 new SyncChangeProcessorWrapperForTest(sync_processor_.get())); |
| 108 } | 108 } |
| 109 | 109 |
| 110 scoped_ptr<SyncErrorFactory> CreateAndPassSyncErrorFactory() { | 110 scoped_ptr<SyncErrorFactory> CreateAndPassSyncErrorFactory() { |
| 111 return scoped_ptr<SyncErrorFactory>(new SyncErrorFactoryMock()); | 111 return scoped_ptr<SyncErrorFactory>(new SyncErrorFactoryMock()); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 EXPECT_EQ("client_1", sync_processor_->client_name_at(0)); | 547 EXPECT_EQ("client_1", sync_processor_->client_name_at(0)); |
| 548 | 548 |
| 549 backup_time = syncer::ProtoTimeToTime( | 549 backup_time = syncer::ProtoTimeToTime( |
| 550 sync_processor_->device_info_at(0).backup_timestamp()); | 550 sync_processor_->device_info_at(0).backup_timestamp()); |
| 551 EXPECT_EQ(6000, backup_time.ToTimeT()); | 551 EXPECT_EQ(6000, backup_time.ToTimeT()); |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace | 554 } // namespace |
| 555 | 555 |
| 556 } // namespace sync_driver | 556 } // namespace sync_driver |
| OLD | NEW |