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

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

Issue 2422253002: [Sync] Rewriting ".reset(new" pattern to use "= base::MakeUnique" instead. (Closed)
Patch Set: Fixing compile. Created 4 years, 2 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/device_info/device_info_sync_service.h" 5 #include "components/sync/device_info/device_info_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "components/sync/base/time.h" 11 #include "components/sync/base/time.h"
11 #include "components/sync/device_info/device_info_util.h" 12 #include "components/sync/device_info/device_info_util.h"
12 #include "components/sync/device_info/local_device_info_provider_mock.h" 13 #include "components/sync/device_info/local_device_info_provider_mock.h"
13 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h" 14 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h"
14 #include "components/sync/model/sync_change_processor_wrapper_for_test.h" 15 #include "components/sync/model/sync_change_processor_wrapper_for_test.h"
15 #include "components/sync/model/sync_error_factory_mock.h" 16 #include "components/sync/model/sync_error_factory_mock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using base::Time; 19 using base::Time;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 68
68 } // namespace 69 } // namespace
69 70
70 class DeviceInfoSyncServiceTest : public testing::Test, 71 class DeviceInfoSyncServiceTest : public testing::Test,
71 public DeviceInfoTracker::Observer { 72 public DeviceInfoTracker::Observer {
72 public: 73 public:
73 DeviceInfoSyncServiceTest() : num_device_info_changed_callbacks_(0) {} 74 DeviceInfoSyncServiceTest() : num_device_info_changed_callbacks_(0) {}
74 ~DeviceInfoSyncServiceTest() override {} 75 ~DeviceInfoSyncServiceTest() override {}
75 76
76 void SetUp() override { 77 void SetUp() override {
77 local_device_.reset(new LocalDeviceInfoProviderMock( 78 local_device_ = base::MakeUnique<LocalDeviceInfoProviderMock>(
78 "guid_1", "client_1", "Chromium 10k", "Chrome 10k", 79 "guid_1", "client_1", "Chromium 10k", "Chrome 10k",
79 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id")); 80 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id");
80 sync_service_.reset(new DeviceInfoSyncService(local_device_.get())); 81 sync_service_ =
81 sync_processor_.reset(new TestChangeProcessor()); 82 base::MakeUnique<DeviceInfoSyncService>(local_device_.get());
82 // Register observer 83 sync_processor_ = base::MakeUnique<TestChangeProcessor>();
83 sync_service_->AddObserver(this); 84 sync_service_->AddObserver(this);
84 } 85 }
85 86
86 void TearDown() override { sync_service_->RemoveObserver(this); } 87 void TearDown() override { sync_service_->RemoveObserver(this); }
87 88
88 void OnDeviceInfoChange() override { num_device_info_changed_callbacks_++; } 89 void OnDeviceInfoChange() override { num_device_info_changed_callbacks_++; }
89 90
90 std::unique_ptr<SyncChangeProcessor> PassProcessor() { 91 std::unique_ptr<SyncChangeProcessor> PassProcessor() {
91 return std::unique_ptr<SyncChangeProcessor>( 92 return std::unique_ptr<SyncChangeProcessor>(
92 new SyncChangeProcessorWrapperForTest(sync_processor_.get())); 93 new SyncChangeProcessorWrapperForTest(sync_processor_.get()));
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 sync_pb::EntitySpecifics entity; 549 sync_pb::EntitySpecifics entity;
549 sync_pb::DeviceInfoSpecifics& specifics = *entity.mutable_device_info(); 550 sync_pb::DeviceInfoSpecifics& specifics = *entity.mutable_device_info();
550 specifics.set_cache_guid("stale"); 551 specifics.set_cache_guid("stale");
551 StoreSyncData("stale", SyncData::CreateLocalData("stale", "stale", entity)); 552 StoreSyncData("stale", SyncData::CreateLocalData("stale", "stale", entity));
552 EXPECT_EQ(0, CountActiveDevices(Time() + DeviceInfoUtil::kActiveThreshold)); 553 EXPECT_EQ(0, CountActiveDevices(Time() + DeviceInfoUtil::kActiveThreshold));
553 } 554 }
554 555
555 } // namespace 556 } // namespace
556 557
557 } // namespace syncer 558 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698