Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: components/sync_driver/device_info_sync_service_unittest.cc

Issue 1907683003: Convert //components/sync_driver from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/sync_driver/device_info_sync_service.h" 5 #include "components/sync_driver/device_info_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 sync_service_.reset(new DeviceInfoSyncService(local_device_.get())); 100 sync_service_.reset(new DeviceInfoSyncService(local_device_.get()));
101 sync_processor_.reset(new TestChangeProcessor()); 101 sync_processor_.reset(new TestChangeProcessor());
102 // Register observer 102 // Register observer
103 sync_service_->AddObserver(this); 103 sync_service_->AddObserver(this);
104 } 104 }
105 105
106 void TearDown() override { sync_service_->RemoveObserver(this); } 106 void TearDown() override { sync_service_->RemoveObserver(this); }
107 107
108 void OnDeviceInfoChange() override { num_device_info_changed_callbacks_++; } 108 void OnDeviceInfoChange() override { num_device_info_changed_callbacks_++; }
109 109
110 scoped_ptr<SyncChangeProcessor> PassProcessor() { 110 std::unique_ptr<SyncChangeProcessor> PassProcessor() {
111 return scoped_ptr<SyncChangeProcessor>( 111 return std::unique_ptr<SyncChangeProcessor>(
112 new SyncChangeProcessorWrapperForTest(sync_processor_.get())); 112 new SyncChangeProcessorWrapperForTest(sync_processor_.get()));
113 } 113 }
114 114
115 scoped_ptr<SyncErrorFactory> CreateAndPassSyncErrorFactory() { 115 std::unique_ptr<SyncErrorFactory> CreateAndPassSyncErrorFactory() {
116 return scoped_ptr<SyncErrorFactory>(new SyncErrorFactoryMock()); 116 return std::unique_ptr<SyncErrorFactory>(new SyncErrorFactoryMock());
117 } 117 }
118 118
119 // Default |last_updated_timestamp| to now to avoid pulse update on merge. 119 // Default |last_updated_timestamp| to now to avoid pulse update on merge.
120 SyncData CreateRemoteData(const std::string& client_id, 120 SyncData CreateRemoteData(const std::string& client_id,
121 const std::string& client_name, 121 const std::string& client_name,
122 Time last_updated_timestamp = Time::Now()) { 122 Time last_updated_timestamp = Time::Now()) {
123 sync_pb::EntitySpecifics entity; 123 sync_pb::EntitySpecifics entity;
124 sync_pb::DeviceInfoSpecifics& specifics = *entity.mutable_device_info(); 124 sync_pb::DeviceInfoSpecifics& specifics = *entity.mutable_device_info();
125 125
126 specifics.set_cache_guid(client_id); 126 specifics.set_cache_guid(client_id);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 void StoreSyncData(const std::string& client_id, 163 void StoreSyncData(const std::string& client_id,
164 const syncer::SyncData& sync_data) { 164 const syncer::SyncData& sync_data) {
165 sync_service_->StoreSyncData(client_id, sync_data); 165 sync_service_->StoreSyncData(client_id, sync_data);
166 } 166 }
167 bool IsPulseTimerRunning() { return sync_service_->pulse_timer_.IsRunning(); } 167 bool IsPulseTimerRunning() { return sync_service_->pulse_timer_.IsRunning(); }
168 168
169 // Needs to be created for OneShotTimer to grab the current task runner. 169 // Needs to be created for OneShotTimer to grab the current task runner.
170 base::MessageLoop message_loop_; 170 base::MessageLoop message_loop_;
171 171
172 int num_device_info_changed_callbacks_; 172 int num_device_info_changed_callbacks_;
173 scoped_ptr<LocalDeviceInfoProviderMock> local_device_; 173 std::unique_ptr<LocalDeviceInfoProviderMock> local_device_;
174 scoped_ptr<DeviceInfoSyncService> sync_service_; 174 std::unique_ptr<DeviceInfoSyncService> sync_service_;
175 scoped_ptr<TestChangeProcessor> sync_processor_; 175 std::unique_ptr<TestChangeProcessor> sync_processor_;
176 }; 176 };
177 177
178 namespace { 178 namespace {
179 179
180 // Sync with empty initial data. 180 // Sync with empty initial data.
181 TEST_F(DeviceInfoSyncServiceTest, StartSyncEmptyInitialData) { 181 TEST_F(DeviceInfoSyncServiceTest, StartSyncEmptyInitialData) {
182 EXPECT_FALSE(sync_service_->IsSyncing()); 182 EXPECT_FALSE(sync_service_->IsSyncing());
183 183
184 SyncMergeResult merge_result = 184 SyncMergeResult merge_result =
185 sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO, 185 sync_service_->MergeDataAndStartSyncing(syncer::DEVICE_INFO,
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 sync_pb::EntitySpecifics entity; 594 sync_pb::EntitySpecifics entity;
595 sync_pb::DeviceInfoSpecifics& specifics = *entity.mutable_device_info(); 595 sync_pb::DeviceInfoSpecifics& specifics = *entity.mutable_device_info();
596 specifics.set_cache_guid("stale"); 596 specifics.set_cache_guid("stale");
597 StoreSyncData("stale", SyncData::CreateLocalData("stale", "stale", entity)); 597 StoreSyncData("stale", SyncData::CreateLocalData("stale", "stale", entity));
598 EXPECT_EQ(0, CountActiveDevices(Time() + kStaleDeviceInfoThreshold)); 598 EXPECT_EQ(0, CountActiveDevices(Time() + kStaleDeviceInfoThreshold));
599 } 599 }
600 600
601 } // namespace 601 } // namespace
602 602
603 } // namespace sync_driver 603 } // namespace sync_driver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698