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

Side by Side Diff: chrome/browser/sync_file_system/sync_file_system_service_unittest.cc

Issue 1873683002: Convert //chrome/browser/sync_file_system 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/sync_file_system/sync_file_system_service.h" 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 content::TestBrowserThreadBundle::REAL_IO_THREAD) {} 134 content::TestBrowserThreadBundle::REAL_IO_THREAD) {}
135 135
136 void SetUp() override { 136 void SetUp() override {
137 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); 137 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
138 file_system_.reset(new CannedSyncableFileSystem( 138 file_system_.reset(new CannedSyncableFileSystem(
139 GURL(kOrigin), 139 GURL(kOrigin),
140 in_memory_env_.get(), 140 in_memory_env_.get(),
141 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), 141 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
142 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); 142 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)));
143 143
144 scoped_ptr<LocalFileSyncService> local_service = 144 std::unique_ptr<LocalFileSyncService> local_service =
145 LocalFileSyncService::CreateForTesting(&profile_, in_memory_env_.get()); 145 LocalFileSyncService::CreateForTesting(&profile_, in_memory_env_.get());
146 remote_service_ = new StrictMock<MockRemoteFileSyncService>; 146 remote_service_ = new StrictMock<MockRemoteFileSyncService>;
147 sync_service_.reset(new SyncFileSystemService(&profile_)); 147 sync_service_.reset(new SyncFileSystemService(&profile_));
148 148
149 EXPECT_CALL(*mock_remote_service(), 149 EXPECT_CALL(*mock_remote_service(),
150 AddServiceObserver(_)).Times(1); 150 AddServiceObserver(_)).Times(1);
151 EXPECT_CALL(*mock_remote_service(), 151 EXPECT_CALL(*mock_remote_service(),
152 AddFileStatusObserver(sync_service_.get())).Times(1); 152 AddFileStatusObserver(sync_service_.get())).Times(1);
153 EXPECT_CALL(*mock_remote_service(), 153 EXPECT_CALL(*mock_remote_service(),
154 GetLocalChangeProcessor()) 154 GetLocalChangeProcessor())
155 .WillRepeatedly(Return(&local_change_processor_)); 155 .WillRepeatedly(Return(&local_change_processor_));
156 EXPECT_CALL(*mock_remote_service(), 156 EXPECT_CALL(*mock_remote_service(),
157 SetRemoteChangeProcessor(local_service.get())).Times(1); 157 SetRemoteChangeProcessor(local_service.get())).Times(1);
158 158
159 sync_service_->Initialize( 159 sync_service_->Initialize(
160 std::move(local_service), 160 std::move(local_service),
161 scoped_ptr<RemoteFileSyncService>(remote_service_)); 161 std::unique_ptr<RemoteFileSyncService>(remote_service_));
162 162
163 // Disable auto sync by default. 163 // Disable auto sync by default.
164 EXPECT_CALL(*mock_remote_service(), SetSyncEnabled(false)).Times(1); 164 EXPECT_CALL(*mock_remote_service(), SetSyncEnabled(false)).Times(1);
165 sync_service_->SetSyncEnabledForTesting(false); 165 sync_service_->SetSyncEnabledForTesting(false);
166 166
167 file_system_->SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); 167 file_system_->SetUp(CannedSyncableFileSystem::QUOTA_ENABLED);
168 } 168 }
169 169
170 void TearDown() override { 170 void TearDown() override {
171 sync_service_->Shutdown(); 171 sync_service_->Shutdown();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 StrictMock<MockLocalChangeProcessor>* mock_local_change_processor() { 257 StrictMock<MockLocalChangeProcessor>* mock_local_change_processor() {
258 return &local_change_processor_; 258 return &local_change_processor_;
259 } 259 }
260 260
261 void EnableSync() { 261 void EnableSync() {
262 EXPECT_CALL(*mock_remote_service(), SetSyncEnabled(true)).Times(1); 262 EXPECT_CALL(*mock_remote_service(), SetSyncEnabled(true)).Times(1);
263 sync_service_->SetSyncEnabledForTesting(true); 263 sync_service_->SetSyncEnabledForTesting(true);
264 } 264 }
265 265
266 content::TestBrowserThreadBundle thread_bundle_; 266 content::TestBrowserThreadBundle thread_bundle_;
267 scoped_ptr<leveldb::Env> in_memory_env_; 267 std::unique_ptr<leveldb::Env> in_memory_env_;
268 TestingProfile profile_; 268 TestingProfile profile_;
269 scoped_ptr<CannedSyncableFileSystem> file_system_; 269 std::unique_ptr<CannedSyncableFileSystem> file_system_;
270 270
271 // Their ownerships are transferred to SyncFileSystemService. 271 // Their ownerships are transferred to SyncFileSystemService.
272 StrictMock<MockRemoteFileSyncService>* remote_service_; 272 StrictMock<MockRemoteFileSyncService>* remote_service_;
273 StrictMock<MockLocalChangeProcessor> local_change_processor_; 273 StrictMock<MockLocalChangeProcessor> local_change_processor_;
274 274
275 scoped_ptr<SyncFileSystemService> sync_service_; 275 std::unique_ptr<SyncFileSystemService> sync_service_;
276 }; 276 };
277 277
278 TEST_F(SyncFileSystemServiceTest, InitializeForApp) { 278 TEST_F(SyncFileSystemServiceTest, InitializeForApp) {
279 InitializeApp(); 279 InitializeApp();
280 } 280 }
281 281
282 TEST_F(SyncFileSystemServiceTest, InitializeForAppSuccess) { 282 TEST_F(SyncFileSystemServiceTest, InitializeForAppSuccess) {
283 std::vector<SyncServiceState> expected_states; 283 std::vector<SyncServiceState> expected_states;
284 expected_states.push_back(SYNC_SERVICE_RUNNING); 284 expected_states.push_back(SYNC_SERVICE_RUNNING);
285 285
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 base::Bind(&AssignValueAndQuit<SyncFileStatus>, 483 base::Bind(&AssignValueAndQuit<SyncFileStatus>,
484 &run_loop, &status, &sync_file_status)); 484 &run_loop, &status, &sync_file_status));
485 run_loop.Run(); 485 run_loop.Run();
486 486
487 EXPECT_EQ(SYNC_STATUS_OK, status); 487 EXPECT_EQ(SYNC_STATUS_OK, status);
488 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); 488 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status);
489 } 489 }
490 } 490 }
491 491
492 } // namespace sync_file_system 492 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698