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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_engine_initializer_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/drive_backend/sync_engine_initializer. h" 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer. h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 23 matching lines...) Expand all
34 34
35 namespace { 35 namespace {
36 36
37 const int64_t kInitialLargestChangeID = 1234; 37 const int64_t kInitialLargestChangeID = 1234;
38 38
39 } // namespace 39 } // namespace
40 40
41 class SyncEngineInitializerTest : public testing::Test { 41 class SyncEngineInitializerTest : public testing::Test {
42 public: 42 public:
43 struct TrackedFile { 43 struct TrackedFile {
44 scoped_ptr<google_apis::FileResource> resource; 44 std::unique_ptr<google_apis::FileResource> resource;
45 FileMetadata metadata; 45 FileMetadata metadata;
46 FileTracker tracker; 46 FileTracker tracker;
47 }; 47 };
48 48
49 SyncEngineInitializerTest() {} 49 SyncEngineInitializerTest() {}
50 ~SyncEngineInitializerTest() override {} 50 ~SyncEngineInitializerTest() override {}
51 51
52 void SetUp() override { 52 void SetUp() override {
53 ASSERT_TRUE(database_dir_.CreateUniqueTempDir()); 53 ASSERT_TRUE(database_dir_.CreateUniqueTempDir());
54 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); 54 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
55 55
56 scoped_ptr<drive::FakeDriveService> 56 std::unique_ptr<drive::FakeDriveService> fake_drive_service(
57 fake_drive_service(new drive::FakeDriveService); 57 new drive::FakeDriveService);
58 fake_drive_service_ = fake_drive_service.get(); 58 fake_drive_service_ = fake_drive_service.get();
59 59
60 sync_context_.reset(new SyncEngineContext( 60 sync_context_.reset(new SyncEngineContext(
61 std::move(fake_drive_service), 61 std::move(fake_drive_service),
62 scoped_ptr<drive::DriveUploaderInterface>(), nullptr /* task_logger */, 62 std::unique_ptr<drive::DriveUploaderInterface>(),
63 base::ThreadTaskRunnerHandle::Get(), 63 nullptr /* task_logger */, base::ThreadTaskRunnerHandle::Get(),
64 base::ThreadTaskRunnerHandle::Get(), nullptr /* worker_pool */)); 64 base::ThreadTaskRunnerHandle::Get(), nullptr /* worker_pool */));
65 65
66 sync_task_manager_.reset(new SyncTaskManager( 66 sync_task_manager_.reset(new SyncTaskManager(
67 base::WeakPtr<SyncTaskManager::Client>(), 67 base::WeakPtr<SyncTaskManager::Client>(),
68 1 /* maximum_parallel_task */, 68 1 /* maximum_parallel_task */,
69 base::ThreadTaskRunnerHandle::Get(), 69 base::ThreadTaskRunnerHandle::Get(),
70 nullptr /* worker_pool */)); 70 nullptr /* worker_pool */));
71 sync_task_manager_->Initialize(SYNC_STATUS_OK); 71 sync_task_manager_->Initialize(SYNC_STATUS_OK);
72 } 72 }
73 73
74 void TearDown() override { 74 void TearDown() override {
75 sync_task_manager_.reset(); 75 sync_task_manager_.reset();
76 metadata_database_.reset(); 76 metadata_database_.reset();
77 sync_context_.reset(); 77 sync_context_.reset();
78 base::RunLoop().RunUntilIdle(); 78 base::RunLoop().RunUntilIdle();
79 } 79 }
80 80
81 base::FilePath database_path() { 81 base::FilePath database_path() {
82 return database_dir_.path(); 82 return database_dir_.path();
83 } 83 }
84 84
85 SyncStatusCode RunInitializer() { 85 SyncStatusCode RunInitializer() {
86 SyncEngineInitializer* initializer = 86 SyncEngineInitializer* initializer =
87 new SyncEngineInitializer(sync_context_.get(), 87 new SyncEngineInitializer(sync_context_.get(),
88 database_path(), 88 database_path(),
89 in_memory_env_.get()); 89 in_memory_env_.get());
90 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 90 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
91 91
92 sync_task_manager_->ScheduleSyncTask( 92 sync_task_manager_->ScheduleSyncTask(
93 FROM_HERE, 93 FROM_HERE, std::unique_ptr<SyncTask>(initializer),
94 scoped_ptr<SyncTask>(initializer),
95 SyncTaskManager::PRIORITY_MED, 94 SyncTaskManager::PRIORITY_MED,
96 base::Bind(&SyncEngineInitializerTest::DidRunInitializer, 95 base::Bind(&SyncEngineInitializerTest::DidRunInitializer,
97 base::Unretained(this), initializer, &status)); 96 base::Unretained(this), initializer, &status));
98 97
99 base::RunLoop().RunUntilIdle(); 98 base::RunLoop().RunUntilIdle();
100 return status; 99 return status;
101 } 100 }
102 101
103 void DidRunInitializer(SyncEngineInitializer* initializer, 102 void DidRunInitializer(SyncEngineInitializer* initializer,
104 SyncStatusCode* status_out, 103 SyncStatusCode* status_out,
105 SyncStatusCode status) { 104 SyncStatusCode status) {
106 *status_out = status; 105 *status_out = status;
107 metadata_database_ = initializer->PassMetadataDatabase(); 106 metadata_database_ = initializer->PassMetadataDatabase();
108 } 107 }
109 108
110 SyncStatusCode PopulateDatabase( 109 SyncStatusCode PopulateDatabase(
111 const google_apis::FileResource& sync_root, 110 const google_apis::FileResource& sync_root,
112 const google_apis::FileResource** app_roots, 111 const google_apis::FileResource** app_roots,
113 size_t app_roots_count) { 112 size_t app_roots_count) {
114 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 113 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
115 scoped_ptr<MetadataDatabase> database = MetadataDatabase::Create( 114 std::unique_ptr<MetadataDatabase> database = MetadataDatabase::Create(
116 database_path(), in_memory_env_.get(), &status); 115 database_path(), in_memory_env_.get(), &status);
117 if (status != SYNC_STATUS_OK) 116 if (status != SYNC_STATUS_OK)
118 return status; 117 return status;
119 118
120 // |app_root_list| must not own the resources here. Be sure to call 119 // |app_root_list| must not own the resources here. Be sure to call
121 // weak_clear later. 120 // weak_clear later.
122 ScopedVector<google_apis::FileResource> app_root_list; 121 ScopedVector<google_apis::FileResource> app_root_list;
123 for (size_t i = 0; i < app_roots_count; ++i) { 122 for (size_t i = 0; i < app_roots_count; ++i) {
124 app_root_list.push_back( 123 app_root_list.push_back(
125 const_cast<google_apis::FileResource*>(app_roots[i])); 124 const_cast<google_apis::FileResource*>(app_roots[i]));
126 } 125 }
127 126
128 status = database->PopulateInitialData( 127 status = database->PopulateInitialData(
129 kInitialLargestChangeID, sync_root, app_root_list); 128 kInitialLargestChangeID, sync_root, app_root_list);
130 129
131 app_root_list.weak_clear(); 130 app_root_list.weak_clear();
132 return status; 131 return status;
133 } 132 }
134 133
135 scoped_ptr<google_apis::FileResource> CreateRemoteFolder( 134 std::unique_ptr<google_apis::FileResource> CreateRemoteFolder(
136 const std::string& parent_folder_id, 135 const std::string& parent_folder_id,
137 const std::string& title) { 136 const std::string& title) {
138 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 137 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
139 scoped_ptr<google_apis::FileResource> entry; 138 std::unique_ptr<google_apis::FileResource> entry;
140 drive::AddNewDirectoryOptions options; 139 drive::AddNewDirectoryOptions options;
141 options.visibility = google_apis::drive::FILE_VISIBILITY_PRIVATE; 140 options.visibility = google_apis::drive::FILE_VISIBILITY_PRIVATE;
142 sync_context_->GetDriveService()->AddNewDirectory( 141 sync_context_->GetDriveService()->AddNewDirectory(
143 parent_folder_id, title, options, 142 parent_folder_id, title, options,
144 CreateResultReceiver(&error, &entry)); 143 CreateResultReceiver(&error, &entry));
145 base::RunLoop().RunUntilIdle(); 144 base::RunLoop().RunUntilIdle();
146 145
147 EXPECT_EQ(google_apis::HTTP_CREATED, error); 146 EXPECT_EQ(google_apis::HTTP_CREATED, error);
148 return entry; 147 return entry;
149 } 148 }
150 149
151 scoped_ptr<google_apis::FileResource> CreateRemoteSyncRoot() { 150 std::unique_ptr<google_apis::FileResource> CreateRemoteSyncRoot() {
152 scoped_ptr<google_apis::FileResource> sync_root( 151 std::unique_ptr<google_apis::FileResource> sync_root(
153 CreateRemoteFolder(std::string(), kSyncRootFolderTitle)); 152 CreateRemoteFolder(std::string(), kSyncRootFolderTitle));
154 153
155 for (size_t i = 0; i < sync_root->parents().size(); ++i) { 154 for (size_t i = 0; i < sync_root->parents().size(); ++i) {
156 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 155 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
157 sync_context_->GetDriveService()->RemoveResourceFromDirectory( 156 sync_context_->GetDriveService()->RemoveResourceFromDirectory(
158 sync_root->parents()[i].file_id(), 157 sync_root->parents()[i].file_id(),
159 sync_root->file_id(), 158 sync_root->file_id(),
160 CreateResultReceiver(&error)); 159 CreateResultReceiver(&error));
161 base::RunLoop().RunUntilIdle(); 160 base::RunLoop().RunUntilIdle();
162 EXPECT_EQ(google_apis::HTTP_NO_CONTENT, error); 161 EXPECT_EQ(google_apis::HTTP_NO_CONTENT, error);
(...skipping 28 matching lines...) Expand all
191 } 190 }
192 191
193 bool HasActiveTracker(const std::string& file_id) { 192 bool HasActiveTracker(const std::string& file_id) {
194 TrackerIDSet trackers; 193 TrackerIDSet trackers;
195 return metadata_database_->FindTrackersByFileID(file_id, &trackers) && 194 return metadata_database_->FindTrackersByFileID(file_id, &trackers) &&
196 trackers.has_active(); 195 trackers.has_active();
197 } 196 }
198 197
199 bool HasNoParent(const std::string& file_id) { 198 bool HasNoParent(const std::string& file_id) {
200 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 199 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
201 scoped_ptr<google_apis::FileResource> entry; 200 std::unique_ptr<google_apis::FileResource> entry;
202 sync_context_->GetDriveService()->GetFileResource( 201 sync_context_->GetDriveService()->GetFileResource(
203 file_id, 202 file_id,
204 CreateResultReceiver(&error, &entry)); 203 CreateResultReceiver(&error, &entry));
205 base::RunLoop().RunUntilIdle(); 204 base::RunLoop().RunUntilIdle();
206 EXPECT_EQ(google_apis::HTTP_SUCCESS, error); 205 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
207 return entry->parents().empty(); 206 return entry->parents().empty();
208 } 207 }
209 208
210 size_t CountFileMetadata() { 209 size_t CountFileMetadata() {
211 return metadata_database_->CountFileMetadata(); 210 return metadata_database_->CountFileMetadata();
(...skipping 10 matching lines...) Expand all
222 sync_context_->GetDriveService()->AddResourceToDirectory( 221 sync_context_->GetDriveService()->AddResourceToDirectory(
223 new_parent_folder_id, file_id, 222 new_parent_folder_id, file_id,
224 CreateResultReceiver(&error)); 223 CreateResultReceiver(&error));
225 base::RunLoop().RunUntilIdle(); 224 base::RunLoop().RunUntilIdle();
226 return error; 225 return error;
227 } 226 }
228 227
229 private: 228 private:
230 content::TestBrowserThreadBundle browser_threads_; 229 content::TestBrowserThreadBundle browser_threads_;
231 base::ScopedTempDir database_dir_; 230 base::ScopedTempDir database_dir_;
232 scoped_ptr<leveldb::Env> in_memory_env_; 231 std::unique_ptr<leveldb::Env> in_memory_env_;
233 232
234 scoped_ptr<MetadataDatabase> metadata_database_; 233 std::unique_ptr<MetadataDatabase> metadata_database_;
235 scoped_ptr<SyncTaskManager> sync_task_manager_; 234 std::unique_ptr<SyncTaskManager> sync_task_manager_;
236 scoped_ptr<SyncEngineContext> sync_context_; 235 std::unique_ptr<SyncEngineContext> sync_context_;
237 drive::FakeDriveService* fake_drive_service_ = nullptr; 236 drive::FakeDriveService* fake_drive_service_ = nullptr;
238 237
239 DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializerTest); 238 DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializerTest);
240 }; 239 };
241 240
242 TEST_F(SyncEngineInitializerTest, EmptyDatabase_NoRemoteSyncRoot) { 241 TEST_F(SyncEngineInitializerTest, EmptyDatabase_NoRemoteSyncRoot) {
243 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer()); 242 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer());
244 243
245 std::string sync_root_folder_id = GetSyncRootFolderID(); 244 std::string sync_root_folder_id = GetSyncRootFolderID();
246 EXPECT_EQ(1u, CountTrackersForFile(sync_root_folder_id)); 245 EXPECT_EQ(1u, CountTrackersForFile(sync_root_folder_id));
247 246
248 EXPECT_TRUE(HasActiveTracker(sync_root_folder_id)); 247 EXPECT_TRUE(HasActiveTracker(sync_root_folder_id));
249 248
250 EXPECT_EQ(1u, CountFileMetadata()); 249 EXPECT_EQ(1u, CountFileMetadata());
251 EXPECT_EQ(1u, CountFileTracker()); 250 EXPECT_EQ(1u, CountFileTracker());
252 EXPECT_TRUE(VerifyFolderVisibility(sync_root_folder_id)); 251 EXPECT_TRUE(VerifyFolderVisibility(sync_root_folder_id));
253 } 252 }
254 253
255 TEST_F(SyncEngineInitializerTest, EmptyDatabase_RemoteSyncRootExists) { 254 TEST_F(SyncEngineInitializerTest, EmptyDatabase_RemoteSyncRootExists) {
256 scoped_ptr<google_apis::FileResource> sync_root( 255 std::unique_ptr<google_apis::FileResource> sync_root(CreateRemoteSyncRoot());
257 CreateRemoteSyncRoot()); 256 std::unique_ptr<google_apis::FileResource> app_root_1(
258 scoped_ptr<google_apis::FileResource> app_root_1(
259 CreateRemoteFolder(sync_root->file_id(), "app-root 1")); 257 CreateRemoteFolder(sync_root->file_id(), "app-root 1"));
260 scoped_ptr<google_apis::FileResource> app_root_2( 258 std::unique_ptr<google_apis::FileResource> app_root_2(
261 CreateRemoteFolder(sync_root->file_id(), "app-root 2")); 259 CreateRemoteFolder(sync_root->file_id(), "app-root 2"));
262 260
263 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer()); 261 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer());
264 262
265 EXPECT_EQ(1u, CountTrackersForFile(sync_root->file_id())); 263 EXPECT_EQ(1u, CountTrackersForFile(sync_root->file_id()));
266 EXPECT_EQ(1u, CountTrackersForFile(app_root_1->file_id())); 264 EXPECT_EQ(1u, CountTrackersForFile(app_root_1->file_id()));
267 EXPECT_EQ(1u, CountTrackersForFile(app_root_2->file_id())); 265 EXPECT_EQ(1u, CountTrackersForFile(app_root_2->file_id()));
268 266
269 EXPECT_TRUE(HasActiveTracker(sync_root->file_id())); 267 EXPECT_TRUE(HasActiveTracker(sync_root->file_id()));
270 EXPECT_FALSE(HasActiveTracker(app_root_1->file_id())); 268 EXPECT_FALSE(HasActiveTracker(app_root_1->file_id()));
271 EXPECT_FALSE(HasActiveTracker(app_root_2->file_id())); 269 EXPECT_FALSE(HasActiveTracker(app_root_2->file_id()));
272 270
273 EXPECT_EQ(3u, CountFileMetadata()); 271 EXPECT_EQ(3u, CountFileMetadata());
274 EXPECT_EQ(3u, CountFileTracker()); 272 EXPECT_EQ(3u, CountFileTracker());
275 } 273 }
276 274
277 TEST_F(SyncEngineInitializerTest, DatabaseAlreadyInitialized) { 275 TEST_F(SyncEngineInitializerTest, DatabaseAlreadyInitialized) {
278 scoped_ptr<google_apis::FileResource> sync_root(CreateRemoteSyncRoot()); 276 std::unique_ptr<google_apis::FileResource> sync_root(CreateRemoteSyncRoot());
279 scoped_ptr<google_apis::FileResource> app_root_1( 277 std::unique_ptr<google_apis::FileResource> app_root_1(
280 CreateRemoteFolder(sync_root->file_id(), "app-root 1")); 278 CreateRemoteFolder(sync_root->file_id(), "app-root 1"));
281 scoped_ptr<google_apis::FileResource> app_root_2( 279 std::unique_ptr<google_apis::FileResource> app_root_2(
282 CreateRemoteFolder(sync_root->file_id(), "app-root 2")); 280 CreateRemoteFolder(sync_root->file_id(), "app-root 2"));
283 281
284 const google_apis::FileResource* app_roots[] = { 282 const google_apis::FileResource* app_roots[] = {
285 app_root_1.get(), app_root_2.get() 283 app_root_1.get(), app_root_2.get()
286 }; 284 };
287 EXPECT_EQ(SYNC_STATUS_OK, 285 EXPECT_EQ(SYNC_STATUS_OK,
288 PopulateDatabase(*sync_root, app_roots, arraysize(app_roots))); 286 PopulateDatabase(*sync_root, app_roots, arraysize(app_roots)));
289 287
290 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer()); 288 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer());
291 289
292 EXPECT_EQ(1u, CountTrackersForFile(sync_root->file_id())); 290 EXPECT_EQ(1u, CountTrackersForFile(sync_root->file_id()));
293 EXPECT_EQ(1u, CountTrackersForFile(app_root_1->file_id())); 291 EXPECT_EQ(1u, CountTrackersForFile(app_root_1->file_id()));
294 EXPECT_EQ(1u, CountTrackersForFile(app_root_2->file_id())); 292 EXPECT_EQ(1u, CountTrackersForFile(app_root_2->file_id()));
295 293
296 EXPECT_TRUE(HasActiveTracker(sync_root->file_id())); 294 EXPECT_TRUE(HasActiveTracker(sync_root->file_id()));
297 EXPECT_FALSE(HasActiveTracker(app_root_1->file_id())); 295 EXPECT_FALSE(HasActiveTracker(app_root_1->file_id()));
298 EXPECT_FALSE(HasActiveTracker(app_root_2->file_id())); 296 EXPECT_FALSE(HasActiveTracker(app_root_2->file_id()));
299 297
300 EXPECT_EQ(3u, CountFileMetadata()); 298 EXPECT_EQ(3u, CountFileMetadata());
301 EXPECT_EQ(3u, CountFileTracker()); 299 EXPECT_EQ(3u, CountFileTracker());
302 } 300 }
303 301
304 TEST_F(SyncEngineInitializerTest, EmptyDatabase_MultiCandidate) { 302 TEST_F(SyncEngineInitializerTest, EmptyDatabase_MultiCandidate) {
305 scoped_ptr<google_apis::FileResource> sync_root_1(CreateRemoteSyncRoot()); 303 std::unique_ptr<google_apis::FileResource> sync_root_1(
306 scoped_ptr<google_apis::FileResource> sync_root_2(CreateRemoteSyncRoot()); 304 CreateRemoteSyncRoot());
305 std::unique_ptr<google_apis::FileResource> sync_root_2(
306 CreateRemoteSyncRoot());
307 307
308 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer()); 308 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer());
309 309
310 EXPECT_EQ(1u, CountTrackersForFile(sync_root_1->file_id())); 310 EXPECT_EQ(1u, CountTrackersForFile(sync_root_1->file_id()));
311 EXPECT_EQ(0u, CountTrackersForFile(sync_root_2->file_id())); 311 EXPECT_EQ(0u, CountTrackersForFile(sync_root_2->file_id()));
312 312
313 EXPECT_TRUE(HasActiveTracker(sync_root_1->file_id())); 313 EXPECT_TRUE(HasActiveTracker(sync_root_1->file_id()));
314 EXPECT_FALSE(HasActiveTracker(sync_root_2->file_id())); 314 EXPECT_FALSE(HasActiveTracker(sync_root_2->file_id()));
315 315
316 EXPECT_EQ(1u, CountFileMetadata()); 316 EXPECT_EQ(1u, CountFileMetadata());
317 EXPECT_EQ(1u, CountFileTracker()); 317 EXPECT_EQ(1u, CountFileTracker());
318 } 318 }
319 319
320 TEST_F(SyncEngineInitializerTest, EmptyDatabase_UndetachedRemoteSyncRoot) { 320 TEST_F(SyncEngineInitializerTest, EmptyDatabase_UndetachedRemoteSyncRoot) {
321 scoped_ptr<google_apis::FileResource> sync_root(CreateRemoteFolder( 321 std::unique_ptr<google_apis::FileResource> sync_root(
322 std::string(), kSyncRootFolderTitle)); 322 CreateRemoteFolder(std::string(), kSyncRootFolderTitle));
323 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer()); 323 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer());
324 324
325 EXPECT_EQ(1u, CountTrackersForFile(sync_root->file_id())); 325 EXPECT_EQ(1u, CountTrackersForFile(sync_root->file_id()));
326 EXPECT_TRUE(HasActiveTracker(sync_root->file_id())); 326 EXPECT_TRUE(HasActiveTracker(sync_root->file_id()));
327 327
328 EXPECT_TRUE(HasNoParent(sync_root->file_id())); 328 EXPECT_TRUE(HasNoParent(sync_root->file_id()));
329 329
330 EXPECT_EQ(1u, CountFileMetadata()); 330 EXPECT_EQ(1u, CountFileMetadata());
331 EXPECT_EQ(1u, CountFileTracker()); 331 EXPECT_EQ(1u, CountFileTracker());
332 } 332 }
333 333
334 TEST_F(SyncEngineInitializerTest, EmptyDatabase_MultiparentSyncRoot) { 334 TEST_F(SyncEngineInitializerTest, EmptyDatabase_MultiparentSyncRoot) {
335 scoped_ptr<google_apis::FileResource> folder(CreateRemoteFolder( 335 std::unique_ptr<google_apis::FileResource> folder(
336 std::string(), "folder")); 336 CreateRemoteFolder(std::string(), "folder"));
337 scoped_ptr<google_apis::FileResource> sync_root(CreateRemoteFolder( 337 std::unique_ptr<google_apis::FileResource> sync_root(
338 std::string(), kSyncRootFolderTitle)); 338 CreateRemoteFolder(std::string(), kSyncRootFolderTitle));
339 AddParentFolder(sync_root->file_id(), folder->file_id()); 339 AddParentFolder(sync_root->file_id(), folder->file_id());
340 340
341 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer()); 341 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer());
342 342
343 EXPECT_EQ(1u, CountTrackersForFile(sync_root->file_id())); 343 EXPECT_EQ(1u, CountTrackersForFile(sync_root->file_id()));
344 EXPECT_TRUE(HasActiveTracker(sync_root->file_id())); 344 EXPECT_TRUE(HasActiveTracker(sync_root->file_id()));
345 345
346 EXPECT_TRUE(HasNoParent(sync_root->file_id())); 346 EXPECT_TRUE(HasNoParent(sync_root->file_id()));
347 347
348 EXPECT_EQ(1u, CountFileMetadata()); 348 EXPECT_EQ(1u, CountFileMetadata());
349 EXPECT_EQ(1u, CountFileTracker()); 349 EXPECT_EQ(1u, CountFileTracker());
350 } 350 }
351 351
352 TEST_F(SyncEngineInitializerTest, EmptyDatabase_FakeRemoteSyncRoot) { 352 TEST_F(SyncEngineInitializerTest, EmptyDatabase_FakeRemoteSyncRoot) {
353 scoped_ptr<google_apis::FileResource> folder(CreateRemoteFolder( 353 std::unique_ptr<google_apis::FileResource> folder(
354 std::string(), "folder")); 354 CreateRemoteFolder(std::string(), "folder"));
355 scoped_ptr<google_apis::FileResource> sync_root(CreateRemoteFolder( 355 std::unique_ptr<google_apis::FileResource> sync_root(
356 folder->file_id(), kSyncRootFolderTitle)); 356 CreateRemoteFolder(folder->file_id(), kSyncRootFolderTitle));
357 357
358 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer()); 358 EXPECT_EQ(SYNC_STATUS_OK, RunInitializer());
359 359
360 EXPECT_EQ(0u, CountTrackersForFile(sync_root->file_id())); 360 EXPECT_EQ(0u, CountTrackersForFile(sync_root->file_id()));
361 EXPECT_FALSE(HasNoParent(sync_root->file_id())); 361 EXPECT_FALSE(HasNoParent(sync_root->file_id()));
362 362
363 EXPECT_EQ(1u, CountFileMetadata()); 363 EXPECT_EQ(1u, CountFileMetadata());
364 EXPECT_EQ(1u, CountFileTracker()); 364 EXPECT_EQ(1u, CountFileTracker());
365 } 365 }
366 366
367 } // namespace drive_backend 367 } // namespace drive_backend
368 } // namespace sync_file_system 368 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698