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

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 | Annotate | Revision Log
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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 base::RunLoop run_loop; 122 base::RunLoop run_loop;
123 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 123 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
124 local_service_->MaybeInitializeFileSystemContext( 124 local_service_->MaybeInitializeFileSystemContext(
125 GURL(kOrigin), file_system_->file_system_context(), 125 GURL(kOrigin), file_system_->file_system_context(),
126 AssignAndQuitCallback(&run_loop, &status)); 126 AssignAndQuitCallback(&run_loop, &status));
127 run_loop.Run(); 127 run_loop.Run();
128 128
129 local_service_->AddChangeObserver(this); 129 local_service_->AddChangeObserver(this);
130 130
131 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->OpenFileSystem()); 131 EXPECT_EQ(base::File::FILE_OK, file_system_->OpenFileSystem());
132 132
133 file_system_->backend()->sync_context()-> 133 file_system_->backend()->sync_context()->
134 set_mock_notify_changes_duration_in_sec(0); 134 set_mock_notify_changes_duration_in_sec(0);
135 } 135 }
136 136
137 virtual void TearDown() OVERRIDE { 137 virtual void TearDown() OVERRIDE {
138 local_service_->Shutdown(); 138 local_service_->Shutdown();
139 file_system_->TearDown(); 139 file_system_->TearDown();
140 RevokeSyncableFileSystem(); 140 RevokeSyncableFileSystem();
141 content::RunAllPendingInMessageLoop(BrowserThread::FILE); 141 content::RunAllPendingInMessageLoop(BrowserThread::FILE);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 SYNC_STATUS_OK, 223 SYNC_STATUS_OK,
224 expected_metadata); 224 expected_metadata);
225 225
226 // Run ApplyRemoteChange for kFile. 226 // Run ApplyRemoteChange for kFile.
227 FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 227 FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
228 SYNC_FILE_TYPE_FILE); 228 SYNC_FILE_TYPE_FILE);
229 EXPECT_EQ(SYNC_STATUS_OK, 229 EXPECT_EQ(SYNC_STATUS_OK,
230 ApplyRemoteChange(change, local_path, kFile)); 230 ApplyRemoteChange(change, local_path, kFile));
231 231
232 // Verify the file is synced. 232 // Verify the file is synced.
233 EXPECT_EQ(base::PLATFORM_FILE_OK, 233 EXPECT_EQ(base::File::FILE_OK,
234 file_system_->VerifyFile(kFile, kTestFileData)); 234 file_system_->VerifyFile(kFile, kTestFileData));
235 235
236 // Run PrepareForProcessRemoteChange for kDir. 236 // Run PrepareForProcessRemoteChange for kDir.
237 PrepareForProcessRemoteChange(kDir, FROM_HERE, 237 PrepareForProcessRemoteChange(kDir, FROM_HERE,
238 SYNC_STATUS_OK, 238 SYNC_STATUS_OK,
239 expected_metadata); 239 expected_metadata);
240 240
241 // Run ApplyRemoteChange for kDir. 241 // Run ApplyRemoteChange for kDir.
242 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 242 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
243 SYNC_FILE_TYPE_DIRECTORY); 243 SYNC_FILE_TYPE_DIRECTORY);
244 EXPECT_EQ(SYNC_STATUS_OK, 244 EXPECT_EQ(SYNC_STATUS_OK,
245 ApplyRemoteChange(change, base::FilePath(), kDir)); 245 ApplyRemoteChange(change, base::FilePath(), kDir));
246 246
247 // Verify the directory. 247 // Verify the directory.
248 EXPECT_EQ(base::PLATFORM_FILE_OK, 248 EXPECT_EQ(base::File::FILE_OK,
249 file_system_->DirectoryExists(kDir)); 249 file_system_->DirectoryExists(kDir));
250 250
251 // Run PrepareForProcessRemoteChange and ApplyRemoteChange for 251 // Run PrepareForProcessRemoteChange and ApplyRemoteChange for
252 // kDir once again for deletion. 252 // kDir once again for deletion.
253 expected_metadata.file_type = SYNC_FILE_TYPE_DIRECTORY; 253 expected_metadata.file_type = SYNC_FILE_TYPE_DIRECTORY;
254 expected_metadata.size = 0; 254 expected_metadata.size = 0;
255 PrepareForProcessRemoteChange(kDir, FROM_HERE, 255 PrepareForProcessRemoteChange(kDir, FROM_HERE,
256 SYNC_STATUS_OK, 256 SYNC_STATUS_OK,
257 expected_metadata); 257 expected_metadata);
258 258
259 change = FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN); 259 change = FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN);
260 EXPECT_EQ(SYNC_STATUS_OK, ApplyRemoteChange(change, base::FilePath(), kDir)); 260 EXPECT_EQ(SYNC_STATUS_OK, ApplyRemoteChange(change, base::FilePath(), kDir));
261 261
262 // Now the directory must have deleted. 262 // Now the directory must have deleted.
263 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, 263 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND,
264 file_system_->DirectoryExists(kDir)); 264 file_system_->DirectoryExists(kDir));
265 } 265 }
266 266
267 TEST_F(LocalFileSyncServiceTest, LocalChangeObserver) { 267 TEST_F(LocalFileSyncServiceTest, LocalChangeObserver) {
268 const FileSystemURL kFile(file_system_->URL("file")); 268 const FileSystemURL kFile(file_system_->URL("file"));
269 const FileSystemURL kDir(file_system_->URL("dir")); 269 const FileSystemURL kDir(file_system_->URL("dir"));
270 const char kTestFileData[] = "0123456789"; 270 const char kTestFileData[] = "0123456789";
271 const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1); 271 const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1);
272 272
273 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile)); 273 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kFile));
274 274
275 EXPECT_EQ(1, num_changes_); 275 EXPECT_EQ(1, num_changes_);
276 276
277 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateDirectory(kDir)); 277 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateDirectory(kDir));
278 EXPECT_EQ(kTestFileDataSize, 278 EXPECT_EQ(kTestFileDataSize,
279 file_system_->WriteString(kFile, kTestFileData)); 279 file_system_->WriteString(kFile, kTestFileData));
280 280
281 EXPECT_EQ(2, num_changes_); 281 EXPECT_EQ(2, num_changes_);
282 } 282 }
283 283
284 #if defined(OS_WIN) 284 #if defined(OS_WIN)
285 // Flaky: http://crbug.com/171487 285 // Flaky: http://crbug.com/171487
286 #define MAYBE_LocalChangeObserverMultipleContexts\ 286 #define MAYBE_LocalChangeObserverMultipleContexts\
287 DISABLED_LocalChangeObserverMultipleContexts 287 DISABLED_LocalChangeObserverMultipleContexts
(...skipping 10 matching lines...) Expand all
298 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); 298 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
299 file_system2.SetUp(); 299 file_system2.SetUp();
300 300
301 base::RunLoop run_loop; 301 base::RunLoop run_loop;
302 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 302 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
303 local_service_->MaybeInitializeFileSystemContext( 303 local_service_->MaybeInitializeFileSystemContext(
304 GURL(kOrigin2), file_system2.file_system_context(), 304 GURL(kOrigin2), file_system2.file_system_context(),
305 AssignAndQuitCallback(&run_loop, &status)); 305 AssignAndQuitCallback(&run_loop, &status));
306 run_loop.Run(); 306 run_loop.Run();
307 307
308 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system2.OpenFileSystem()); 308 EXPECT_EQ(base::File::FILE_OK, file_system2.OpenFileSystem());
309 file_system2.backend()->sync_context()-> 309 file_system2.backend()->sync_context()->
310 set_mock_notify_changes_duration_in_sec(0); 310 set_mock_notify_changes_duration_in_sec(0);
311 311
312 const FileSystemURL kFile1(file_system_->URL("file1")); 312 const FileSystemURL kFile1(file_system_->URL("file1"));
313 const FileSystemURL kFile2(file_system_->URL("file2")); 313 const FileSystemURL kFile2(file_system_->URL("file2"));
314 const FileSystemURL kFile3(file_system2.URL("file3")); 314 const FileSystemURL kFile3(file_system2.URL("file3"));
315 const FileSystemURL kFile4(file_system2.URL("file4")); 315 const FileSystemURL kFile4(file_system2.URL("file4"));
316 316
317 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile1)); 317 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kFile1));
318 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile2)); 318 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kFile2));
319 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system2.CreateFile(kFile3)); 319 EXPECT_EQ(base::File::FILE_OK, file_system2.CreateFile(kFile3));
320 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system2.CreateFile(kFile4)); 320 EXPECT_EQ(base::File::FILE_OK, file_system2.CreateFile(kFile4));
321 321
322 EXPECT_EQ(4, num_changes_); 322 EXPECT_EQ(4, num_changes_);
323 323
324 file_system2.TearDown(); 324 file_system2.TearDown();
325 } 325 }
326 326
327 TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_CreateFile) { 327 TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_CreateFile) {
328 const FileSystemURL kFile(file_system_->URL("foo")); 328 const FileSystemURL kFile(file_system_->URL("foo"));
329 const char kTestFileData[] = "0123456789"; 329 const char kTestFileData[] = "0123456789";
330 const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1); 330 const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1);
331 331
332 base::RunLoop run_loop; 332 base::RunLoop run_loop;
333 333
334 // We should get called OnSyncEnabled and OnWriteEnabled on kFile. 334 // We should get called OnSyncEnabled and OnWriteEnabled on kFile.
335 // (OnWriteEnabled is called because we release lock before returning 335 // (OnWriteEnabled is called because we release lock before returning
336 // from ApplyLocalChange) 336 // from ApplyLocalChange)
337 StrictMock<MockSyncStatusObserver> status_observer; 337 StrictMock<MockSyncStatusObserver> status_observer;
338 EXPECT_CALL(status_observer, OnSyncEnabled(kFile)).Times(AtLeast(1)); 338 EXPECT_CALL(status_observer, OnSyncEnabled(kFile)).Times(AtLeast(1));
339 EXPECT_CALL(status_observer, OnWriteEnabled(kFile)).Times(AtLeast(0)); 339 EXPECT_CALL(status_observer, OnWriteEnabled(kFile)).Times(AtLeast(0));
340 file_system_->AddSyncStatusObserver(&status_observer); 340 file_system_->AddSyncStatusObserver(&status_observer);
341 341
342 // Creates and writes into a file. 342 // Creates and writes into a file.
343 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile)); 343 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kFile));
344 EXPECT_EQ(kTestFileDataSize, 344 EXPECT_EQ(kTestFileDataSize,
345 file_system_->WriteString(kFile, std::string(kTestFileData))); 345 file_system_->WriteString(kFile, std::string(kTestFileData)));
346 346
347 // Retrieve the expected file info. 347 // Retrieve the expected file info.
348 base::PlatformFileInfo info; 348 base::File::Info info;
349 base::FilePath platform_path; 349 base::FilePath platform_path;
350 EXPECT_EQ(base::PLATFORM_FILE_OK, 350 EXPECT_EQ(base::File::FILE_OK,
351 file_system_->GetMetadataAndPlatformPath( 351 file_system_->GetMetadataAndPlatformPath(
352 kFile, &info, &platform_path)); 352 kFile, &info, &platform_path));
353 353
354 ASSERT_FALSE(info.is_directory); 354 ASSERT_FALSE(info.is_directory);
355 ASSERT_EQ(kTestFileDataSize, info.size); 355 ASSERT_EQ(kTestFileDataSize, info.size);
356 356
357 SyncFileMetadata metadata; 357 SyncFileMetadata metadata;
358 metadata.file_type = SYNC_FILE_TYPE_FILE; 358 metadata.file_type = SYNC_FILE_TYPE_FILE;
359 metadata.size = info.size; 359 metadata.size = info.size;
360 metadata.last_modified = info.last_modified; 360 metadata.last_modified = info.last_modified;
(...skipping 25 matching lines...) Expand all
386 base::RunLoop run_loop; 386 base::RunLoop run_loop;
387 387
388 // We should get called OnSyncEnabled and possibly OnWriteEnabled (depends 388 // We should get called OnSyncEnabled and possibly OnWriteEnabled (depends
389 // on timing) on kFile. 389 // on timing) on kFile.
390 StrictMock<MockSyncStatusObserver> status_observer; 390 StrictMock<MockSyncStatusObserver> status_observer;
391 EXPECT_CALL(status_observer, OnSyncEnabled(kFile)).Times(AtLeast(1)); 391 EXPECT_CALL(status_observer, OnSyncEnabled(kFile)).Times(AtLeast(1));
392 EXPECT_CALL(status_observer, OnWriteEnabled(kFile)).Times(AtLeast(0)); 392 EXPECT_CALL(status_observer, OnWriteEnabled(kFile)).Times(AtLeast(0));
393 file_system_->AddSyncStatusObserver(&status_observer); 393 file_system_->AddSyncStatusObserver(&status_observer);
394 394
395 // Creates and then deletes a file. 395 // Creates and then deletes a file.
396 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile)); 396 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kFile));
397 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->Remove(kFile, false)); 397 EXPECT_EQ(base::File::FILE_OK, file_system_->Remove(kFile, false));
398 398
399 // The local_change_processor's ApplyLocalChange should be called once 399 // The local_change_processor's ApplyLocalChange should be called once
400 // with DELETE change for TYPE_FILE. 400 // with DELETE change for TYPE_FILE.
401 // The file will NOT exist in the remote side and the processor might 401 // The file will NOT exist in the remote side and the processor might
402 // return SYNC_FILE_ERROR_NOT_FOUND (as mocked). 402 // return SYNC_FILE_ERROR_NOT_FOUND (as mocked).
403 StrictMock<MockLocalChangeProcessor> local_change_processor; 403 StrictMock<MockLocalChangeProcessor> local_change_processor;
404 const FileChange change(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_FILE); 404 const FileChange change(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_FILE);
405 EXPECT_CALL(local_change_processor, ApplyLocalChange(change, _, _, kFile, _)) 405 EXPECT_CALL(local_change_processor, ApplyLocalChange(change, _, _, kFile, _))
406 .WillOnce(MockStatusCallback(SYNC_FILE_ERROR_NOT_FOUND)); 406 .WillOnce(MockStatusCallback(SYNC_FILE_ERROR_NOT_FOUND));
407 407
(...skipping 14 matching lines...) Expand all
422 const FileSystemURL kDir(file_system_->URL("foo")); 422 const FileSystemURL kDir(file_system_->URL("foo"));
423 423
424 base::RunLoop run_loop; 424 base::RunLoop run_loop;
425 425
426 // OnSyncEnabled is expected to be called at least or more than once. 426 // OnSyncEnabled is expected to be called at least or more than once.
427 StrictMock<MockSyncStatusObserver> status_observer; 427 StrictMock<MockSyncStatusObserver> status_observer;
428 EXPECT_CALL(status_observer, OnSyncEnabled(kDir)).Times(AtLeast(1)); 428 EXPECT_CALL(status_observer, OnSyncEnabled(kDir)).Times(AtLeast(1));
429 file_system_->AddSyncStatusObserver(&status_observer); 429 file_system_->AddSyncStatusObserver(&status_observer);
430 430
431 // Creates and then deletes a directory. 431 // Creates and then deletes a directory.
432 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateDirectory(kDir)); 432 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateDirectory(kDir));
433 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->Remove(kDir, false)); 433 EXPECT_EQ(base::File::FILE_OK, file_system_->Remove(kDir, false));
434 434
435 // The local_change_processor's ApplyLocalChange should never be called. 435 // The local_change_processor's ApplyLocalChange should never be called.
436 StrictMock<MockLocalChangeProcessor> local_change_processor; 436 StrictMock<MockLocalChangeProcessor> local_change_processor;
437 437
438 local_service_->SetLocalChangeProcessor(&local_change_processor); 438 local_service_->SetLocalChangeProcessor(&local_change_processor);
439 local_service_->ProcessLocalChange( 439 local_service_->ProcessLocalChange(
440 base::Bind(&OnSyncCompleted, FROM_HERE, run_loop.QuitClosure(), 440 base::Bind(&OnSyncCompleted, FROM_HERE, run_loop.QuitClosure(),
441 SYNC_STATUS_NO_CHANGE_TO_SYNC, FileSystemURL())); 441 SYNC_STATUS_NO_CHANGE_TO_SYNC, FileSystemURL()));
442 442
443 run_loop.Run(); 443 run_loop.Run();
(...skipping 11 matching lines...) Expand all
455 455
456 // We should get called OnSyncEnabled and OnWriteEnabled on kPath and 456 // We should get called OnSyncEnabled and OnWriteEnabled on kPath and
457 // OnSyncEnabled on kOther. 457 // OnSyncEnabled on kOther.
458 StrictMock<MockSyncStatusObserver> status_observer; 458 StrictMock<MockSyncStatusObserver> status_observer;
459 EXPECT_CALL(status_observer, OnSyncEnabled(kPath)).Times(AtLeast(1)); 459 EXPECT_CALL(status_observer, OnSyncEnabled(kPath)).Times(AtLeast(1));
460 EXPECT_CALL(status_observer, OnSyncEnabled(kOther)).Times(AtLeast(1)); 460 EXPECT_CALL(status_observer, OnSyncEnabled(kOther)).Times(AtLeast(1));
461 file_system_->AddSyncStatusObserver(&status_observer); 461 file_system_->AddSyncStatusObserver(&status_observer);
462 462
463 // Creates a file, delete the file and creates a directory with the same 463 // Creates a file, delete the file and creates a directory with the same
464 // name. 464 // name.
465 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kPath)); 465 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kPath));
466 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->Remove(kPath, false)); 466 EXPECT_EQ(base::File::FILE_OK, file_system_->Remove(kPath, false));
467 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateDirectory(kPath)); 467 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateDirectory(kPath));
468 468
469 // Creates one more file. 469 // Creates one more file.
470 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kOther)); 470 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kOther));
471 471
472 // The local_change_processor's ApplyLocalChange will be called 472 // The local_change_processor's ApplyLocalChange will be called
473 // twice for FILE_TYPE and FILE_DIRECTORY. 473 // twice for FILE_TYPE and FILE_DIRECTORY.
474 StrictMock<MockLocalChangeProcessor> local_change_processor; 474 StrictMock<MockLocalChangeProcessor> local_change_processor;
475 std::vector<FileChange> changes; 475 std::vector<FileChange> changes;
476 EXPECT_CALL(local_change_processor, ApplyLocalChange(_, _, _, kPath, _)) 476 EXPECT_CALL(local_change_processor, ApplyLocalChange(_, _, _, kPath, _))
477 .Times(2) 477 .Times(2)
478 .WillOnce(MockStatusCallbackAndRecordChange(SYNC_STATUS_OK, &changes)) 478 .WillOnce(MockStatusCallbackAndRecordChange(SYNC_STATUS_OK, &changes))
479 .WillOnce(MockStatusCallbackAndRecordChange(SYNC_STATUS_OK, &changes)); 479 .WillOnce(MockStatusCallbackAndRecordChange(SYNC_STATUS_OK, &changes));
480 local_service_->SetLocalChangeProcessor(&local_change_processor); 480 local_service_->SetLocalChangeProcessor(&local_change_processor);
(...skipping 22 matching lines...) Expand all
503 } 503 }
504 504
505 TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_GetLocalMetadata) { 505 TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_GetLocalMetadata) {
506 const FileSystemURL kURL(file_system_->URL("foo")); 506 const FileSystemURL kURL(file_system_->URL("foo"));
507 const base::Time kTime = base::Time::FromDoubleT(333); 507 const base::Time kTime = base::Time::FromDoubleT(333);
508 const int kSize = 555; 508 const int kSize = 555;
509 509
510 base::RunLoop run_loop; 510 base::RunLoop run_loop;
511 511
512 // Creates a file. 512 // Creates a file.
513 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kURL)); 513 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kURL));
514 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->TruncateFile(kURL, kSize)); 514 EXPECT_EQ(base::File::FILE_OK, file_system_->TruncateFile(kURL, kSize));
515 EXPECT_EQ(base::PLATFORM_FILE_OK, 515 EXPECT_EQ(base::File::FILE_OK,
516 file_system_->TouchFile(kURL, base::Time(), kTime)); 516 file_system_->TouchFile(kURL, base::Time(), kTime));
517 517
518 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 518 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
519 SyncFileMetadata metadata; 519 SyncFileMetadata metadata;
520 local_service_->GetLocalFileMetadata( 520 local_service_->GetLocalFileMetadata(
521 kURL, 521 kURL,
522 base::Bind(&OnGetFileMetadata, FROM_HERE, run_loop.QuitClosure(), 522 base::Bind(&OnGetFileMetadata, FROM_HERE, run_loop.QuitClosure(),
523 &status, &metadata)); 523 &status, &metadata));
524 524
525 run_loop.Run(); 525 run_loop.Run();
526 526
527 EXPECT_EQ(SYNC_STATUS_OK, status); 527 EXPECT_EQ(SYNC_STATUS_OK, status);
528 EXPECT_EQ(kTime, metadata.last_modified); 528 EXPECT_EQ(kTime, metadata.last_modified);
529 EXPECT_EQ(kSize, metadata.size); 529 EXPECT_EQ(kSize, metadata.size);
530 } 530 }
531 531
532 TEST_F(LocalFileSyncServiceTest, RecordFakeChange) { 532 TEST_F(LocalFileSyncServiceTest, RecordFakeChange) {
533 const FileSystemURL kURL(file_system_->URL("foo")); 533 const FileSystemURL kURL(file_system_->URL("foo"));
534 534
535 // Create a file and reset the changes (as preparation). 535 // Create a file and reset the changes (as preparation).
536 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kURL)); 536 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kURL));
537 file_system_->ClearChangeForURLInTracker(kURL); 537 file_system_->ClearChangeForURLInTracker(kURL);
538 538
539 EXPECT_EQ(0, GetNumChangesInTracker()); 539 EXPECT_EQ(0, GetNumChangesInTracker());
540 540
541 fileapi::FileSystemURLSet urlset; 541 fileapi::FileSystemURLSet urlset;
542 file_system_->GetChangedURLsInTracker(&urlset); 542 file_system_->GetChangedURLsInTracker(&urlset);
543 EXPECT_TRUE(urlset.empty()); 543 EXPECT_TRUE(urlset.empty());
544 544
545 const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 545 const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
546 SYNC_FILE_TYPE_FILE); 546 SYNC_FILE_TYPE_FILE);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 all_origins.insert(kOrigin2); 721 all_origins.insert(kOrigin2);
722 all_origins.insert(kOrigin3); 722 all_origins.insert(kOrigin3);
723 while (!all_origins.empty()) { 723 while (!all_origins.empty()) {
724 ASSERT_TRUE(NextOriginToProcess(&origin)); 724 ASSERT_TRUE(NextOriginToProcess(&origin));
725 ASSERT_TRUE(ContainsKey(all_origins, origin)); 725 ASSERT_TRUE(ContainsKey(all_origins, origin));
726 all_origins.erase(origin); 726 all_origins.erase(origin);
727 } 727 }
728 } 728 }
729 729
730 } // namespace sync_file_system 730 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698