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

Side by Side Diff: components/sync/device_info/device_info_service_unittest.cc

Issue 2289143003: [Sync] Convert DTCs to be not RefCounted and NonThreadSafe. (Closed)
Patch Set: Rebase. Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/device_info/device_info_service.h" 5 #include "components/sync/device_info/device_info_service.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "components/sync/api/data_batch.h" 18 #include "components/sync/api/data_batch.h"
19 #include "components/sync/api/data_type_error_handler_mock.h"
19 #include "components/sync/api/entity_data.h" 20 #include "components/sync/api/entity_data.h"
20 #include "components/sync/api/fake_model_type_change_processor.h" 21 #include "components/sync/api/fake_model_type_change_processor.h"
21 #include "components/sync/api/metadata_batch.h" 22 #include "components/sync/api/metadata_batch.h"
22 #include "components/sync/api/model_type_store.h" 23 #include "components/sync/api/model_type_store.h"
23 #include "components/sync/base/time.h" 24 #include "components/sync/base/time.h"
24 #include "components/sync/core/test/data_type_error_handler_mock.h"
25 #include "components/sync/core/test/model_type_store_test_util.h" 25 #include "components/sync/core/test/model_type_store_test_util.h"
26 #include "components/sync/device_info/local_device_info_provider_mock.h" 26 #include "components/sync/device_info/local_device_info_provider_mock.h"
27 #include "components/sync/protocol/data_type_state.pb.h" 27 #include "components/sync/protocol/data_type_state.pb.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 29
30 namespace sync_driver_v2 { 30 namespace sync_driver_v2 {
31 31
32 using base::Time; 32 using base::Time;
33 using base::TimeDelta; 33 using base::TimeDelta;
34 using syncer::SyncError; 34 using syncer::SyncError;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 service_.reset(new DeviceInfoService( 210 service_.reset(new DeviceInfoService(
211 local_device_.get(), 211 local_device_.get(),
212 base::Bind(&ModelTypeStoreTestUtil::MoveStoreToCallback, 212 base::Bind(&ModelTypeStoreTestUtil::MoveStoreToCallback,
213 base::Passed(&store_)), 213 base::Passed(&store_)),
214 base::Bind(&DeviceInfoServiceTest::CreateModelTypeChangeProcessor, 214 base::Bind(&DeviceInfoServiceTest::CreateModelTypeChangeProcessor,
215 base::Unretained(this)))); 215 base::Unretained(this))));
216 service_->AddObserver(this); 216 service_->AddObserver(this);
217 } 217 }
218 218
219 void OnSyncStarting() { 219 void OnSyncStarting() {
220 service()->OnSyncStarting(&error_handler_, StartCallback()); 220 service()->OnSyncStarting(
221 base::MakeUnique<syncer::DataTypeErrorHandlerMock>(), StartCallback());
221 } 222 }
222 223
223 // Creates the service and runs any outstanding tasks. This will typically 224 // Creates the service and runs any outstanding tasks. This will typically
224 // cause all initialization callbacks between the sevice and store to fire. 225 // cause all initialization callbacks between the sevice and store to fire.
225 void InitializeAndPump() { 226 void InitializeAndPump() {
226 InitializeService(); 227 InitializeService();
227 base::RunLoop().RunUntilIdle(); 228 base::RunLoop().RunUntilIdle();
228 } 229 }
229 230
230 // Creates the service, runs any outstanding tasks, and then indicates to the 231 // Creates the service, runs any outstanding tasks, and then indicates to the
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 int change_count_; 317 int change_count_;
317 318
318 // In memory model type store needs a MessageLoop. 319 // In memory model type store needs a MessageLoop.
319 base::MessageLoop message_loop_; 320 base::MessageLoop message_loop_;
320 321
321 // Holds the store while the service is not initialized. 322 // Holds the store while the service is not initialized.
322 std::unique_ptr<ModelTypeStore> store_; 323 std::unique_ptr<ModelTypeStore> store_;
323 324
324 std::unique_ptr<LocalDeviceInfoProviderMock> local_device_; 325 std::unique_ptr<LocalDeviceInfoProviderMock> local_device_;
325 326
326 // Mock error handler passed to the processor.
327 syncer::DataTypeErrorHandlerMock error_handler_;
328
329 // Not initialized immediately (upon test's constructor). This allows each 327 // Not initialized immediately (upon test's constructor). This allows each
330 // test case to modify the dependencies the service will be constructed with. 328 // test case to modify the dependencies the service will be constructed with.
331 std::unique_ptr<DeviceInfoService> service_; 329 std::unique_ptr<DeviceInfoService> service_;
332 330
333 // A non-owning pointer to the processor given to the service. Will be nullptr 331 // A non-owning pointer to the processor given to the service. Will be nullptr
334 // before being given to the service, to make ownership easier. 332 // before being given to the service, to make ownership easier.
335 RecordingModelTypeChangeProcessor* processor_ = nullptr; 333 RecordingModelTypeChangeProcessor* processor_ = nullptr;
336 334
337 // A monotonically increasing label for generated specifics objects with data 335 // A monotonically increasing label for generated specifics objects with data
338 // that is slightly different from eachother. 336 // that is slightly different from eachother.
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 specifics.set_cache_guid("non-local"); 769 specifics.set_cache_guid("non-local");
772 PushBackEntityChangeAdd(specifics, &change_list); 770 PushBackEntityChangeAdd(specifics, &change_list);
773 service()->ApplySyncChanges(service()->CreateMetadataChangeList(), 771 service()->ApplySyncChanges(service()->CreateMetadataChangeList(),
774 change_list); 772 change_list);
775 EXPECT_EQ(1, service()->CountActiveDevices()); 773 EXPECT_EQ(1, service()->CountActiveDevices());
776 } 774 }
777 775
778 } // namespace 776 } // namespace
779 777
780 } // namespace sync_driver_v2 778 } // namespace sync_driver_v2
OLDNEW
« no previous file with comments | « components/sync/device_info/device_info_data_type_controller_unittest.cc ('k') | components/sync/driver/change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698