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

Side by Side Diff: webkit/fileapi/syncable/local_file_sync_context_unittest.cc

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 (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 "webkit/fileapi/syncable/local_file_sync_context.h" 5 #include "webkit/fileapi/syncable/local_file_sync_context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread()); 112 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread());
113 has_inflight_prepare_for_sync_ = false; 113 has_inflight_prepare_for_sync_ = false;
114 status_ = status; 114 status_ = status;
115 *metadata_out = sync_file_info.metadata; 115 *metadata_out = sync_file_info.metadata;
116 *changes_out = sync_file_info.changes; 116 *changes_out = sync_file_info.changes;
117 MessageLoop::current()->Quit(); 117 MessageLoop::current()->Quit();
118 } 118 }
119 119
120 SyncStatusCode ApplyRemoteChange(FileSystemContext* file_system_context, 120 SyncStatusCode ApplyRemoteChange(FileSystemContext* file_system_context,
121 const FileChange& change, 121 const FileChange& change,
122 const FilePath& local_path, 122 const base::FilePath& local_path,
123 const FileSystemURL& url, 123 const FileSystemURL& url,
124 SyncFileType expected_file_type) { 124 SyncFileType expected_file_type) {
125 SCOPED_TRACE(testing::Message() << "ApplyChange for " << 125 SCOPED_TRACE(testing::Message() << "ApplyChange for " <<
126 url.DebugString()); 126 url.DebugString());
127 127
128 // First we should call PrepareForSync to disable writing. 128 // First we should call PrepareForSync to disable writing.
129 SyncFileMetadata metadata; 129 SyncFileMetadata metadata;
130 FileChangeList changes; 130 FileChangeList changes;
131 EXPECT_EQ(SYNC_STATUS_OK, 131 EXPECT_EQ(SYNC_STATUS_OK,
132 PrepareForSync(file_system_context, url, &metadata, &changes)); 132 PrepareForSync(file_system_context, url, &metadata, &changes));
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 int64 new_usage = -1; 424 int64 new_usage = -1;
425 EXPECT_EQ(quota::kQuotaStatusOk, 425 EXPECT_EQ(quota::kQuotaStatusOk,
426 file_system.GetUsageAndQuota(&new_usage, &quota)); 426 file_system.GetUsageAndQuota(&new_usage, &quota));
427 EXPECT_GT(new_usage, initial_usage); 427 EXPECT_GT(new_usage, initial_usage);
428 428
429 // Now let's apply remote deletion changes. 429 // Now let's apply remote deletion changes.
430 FileChange change(FileChange::FILE_CHANGE_DELETE, 430 FileChange change(FileChange::FILE_CHANGE_DELETE,
431 SYNC_FILE_TYPE_FILE); 431 SYNC_FILE_TYPE_FILE);
432 EXPECT_EQ(SYNC_STATUS_OK, 432 EXPECT_EQ(SYNC_STATUS_OK,
433 ApplyRemoteChange(file_system.file_system_context(), 433 ApplyRemoteChange(file_system.file_system_context(),
434 change, FilePath(), kFile, 434 change, base::FilePath(), kFile,
435 SYNC_FILE_TYPE_FILE)); 435 SYNC_FILE_TYPE_FILE));
436 436
437 // The implementation doesn't check file type for deletion, and it must be ok 437 // The implementation doesn't check file type for deletion, and it must be ok
438 // even if we don't know if the deletion change was for a file or a directory. 438 // even if we don't know if the deletion change was for a file or a directory.
439 change = FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN); 439 change = FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN);
440 EXPECT_EQ(SYNC_STATUS_OK, 440 EXPECT_EQ(SYNC_STATUS_OK,
441 ApplyRemoteChange(file_system.file_system_context(), 441 ApplyRemoteChange(file_system.file_system_context(),
442 change, FilePath(), kDir, 442 change, base::FilePath(), kDir,
443 SYNC_FILE_TYPE_DIRECTORY)); 443 SYNC_FILE_TYPE_DIRECTORY));
444 444
445 // Check the directory/files are deleted successfully. 445 // Check the directory/files are deleted successfully.
446 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, 446 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
447 file_system.FileExists(kFile)); 447 file_system.FileExists(kFile));
448 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, 448 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
449 file_system.DirectoryExists(kDir)); 449 file_system.DirectoryExists(kDir));
450 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, 450 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
451 file_system.FileExists(kChild)); 451 file_system.FileExists(kChild));
452 452
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 file_system.DirectoryExists(kDir)); 499 file_system.DirectoryExists(kDir));
500 500
501 // file_system's change tracker must have recorded the creation. 501 // file_system's change tracker must have recorded the creation.
502 FileSystemURLSet urls; 502 FileSystemURLSet urls;
503 file_system.GetChangedURLsInTracker(&urls); 503 file_system.GetChangedURLsInTracker(&urls);
504 ASSERT_EQ(1U, urls.size()); 504 ASSERT_EQ(1U, urls.size());
505 EXPECT_TRUE(ContainsKey(urls, kFile1)); 505 EXPECT_TRUE(ContainsKey(urls, kFile1));
506 file_system.ClearChangeForURLInTracker(*urls.begin()); 506 file_system.ClearChangeForURLInTracker(*urls.begin());
507 507
508 // Prepare temporary files which represent the remote file data. 508 // Prepare temporary files which represent the remote file data.
509 const FilePath kFilePath1(temp_dir.path().Append(FPL("file1"))); 509 const base::FilePath kFilePath1(temp_dir.path().Append(FPL("file1")));
510 const FilePath kFilePath2(temp_dir.path().Append(FPL("file2"))); 510 const base::FilePath kFilePath2(temp_dir.path().Append(FPL("file2")));
511 511
512 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1), 512 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1),
513 file_util::WriteFile(kFilePath1, kTestFileData1, 513 file_util::WriteFile(kFilePath1, kTestFileData1,
514 arraysize(kTestFileData1) - 1)); 514 arraysize(kTestFileData1) - 1));
515 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1), 515 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1),
516 file_util::WriteFile(kFilePath2, kTestFileData2, 516 file_util::WriteFile(kFilePath2, kTestFileData2,
517 arraysize(kTestFileData2) - 1)); 517 arraysize(kTestFileData2) - 1));
518 518
519 // Record the usage. 519 // Record the usage.
520 int64 usage = -1, new_usage = -1; 520 int64 usage = -1, new_usage = -1;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 SYNC_FILE_TYPE_FILE); 558 SYNC_FILE_TYPE_FILE);
559 EXPECT_EQ(SYNC_STATUS_OK, 559 EXPECT_EQ(SYNC_STATUS_OK,
560 ApplyRemoteChange(file_system.file_system_context(), 560 ApplyRemoteChange(file_system.file_system_context(),
561 change, kFilePath2, kFile2, 561 change, kFilePath2, kFile2,
562 SYNC_FILE_TYPE_UNKNOWN)); 562 SYNC_FILE_TYPE_UNKNOWN));
563 563
564 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 564 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
565 SYNC_FILE_TYPE_DIRECTORY); 565 SYNC_FILE_TYPE_DIRECTORY);
566 EXPECT_EQ(SYNC_STATUS_OK, 566 EXPECT_EQ(SYNC_STATUS_OK,
567 ApplyRemoteChange(file_system.file_system_context(), 567 ApplyRemoteChange(file_system.file_system_context(),
568 change, FilePath(), kDir, 568 change, base::FilePath(), kDir,
569 SYNC_FILE_TYPE_UNKNOWN)); 569 SYNC_FILE_TYPE_UNKNOWN));
570 570
571 // This should not happen, but calling ApplyRemoteChange 571 // This should not happen, but calling ApplyRemoteChange
572 // with wrong file type will result in error. 572 // with wrong file type will result in error.
573 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 573 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
574 SYNC_FILE_TYPE_FILE); 574 SYNC_FILE_TYPE_FILE);
575 EXPECT_NE(SYNC_STATUS_OK, 575 EXPECT_NE(SYNC_STATUS_OK,
576 ApplyRemoteChange(file_system.file_system_context(), 576 ApplyRemoteChange(file_system.file_system_context(),
577 change, kFilePath1, kDir, 577 change, kFilePath1, kDir,
578 SYNC_FILE_TYPE_DIRECTORY)); 578 SYNC_FILE_TYPE_DIRECTORY));
(...skipping 15 matching lines...) Expand all
594 // Make sure all three files/directory exist. 594 // Make sure all three files/directory exist.
595 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.FileExists(kFile1)); 595 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.FileExists(kFile1));
596 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.FileExists(kFile2)); 596 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.FileExists(kFile2));
597 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.DirectoryExists(kDir)); 597 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.DirectoryExists(kDir));
598 598
599 sync_context_->ShutdownOnUIThread(); 599 sync_context_->ShutdownOnUIThread();
600 file_system.TearDown(); 600 file_system.TearDown();
601 } 601 }
602 602
603 } // namespace fileapi 603 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/syncable/local_file_sync_context.cc ('k') | webkit/fileapi/syncable/sync_file_metadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698