Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_util.h" | 10 #include "base/file_util.h" |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 change, kFilePath2, kFile2, | 569 change, kFilePath2, kFile2, |
| 570 SYNC_FILE_TYPE_UNKNOWN)); | 570 SYNC_FILE_TYPE_UNKNOWN)); |
| 571 | 571 |
| 572 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 572 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 573 SYNC_FILE_TYPE_DIRECTORY); | 573 SYNC_FILE_TYPE_DIRECTORY); |
| 574 EXPECT_EQ(SYNC_STATUS_OK, | 574 EXPECT_EQ(SYNC_STATUS_OK, |
| 575 ApplyRemoteChange(file_system.file_system_context(), | 575 ApplyRemoteChange(file_system.file_system_context(), |
| 576 change, base::FilePath(), kDir, | 576 change, base::FilePath(), kDir, |
| 577 SYNC_FILE_TYPE_UNKNOWN)); | 577 SYNC_FILE_TYPE_UNKNOWN)); |
| 578 | 578 |
| 579 // This should not happen, but calling ApplyRemoteChange | 579 // Calling ApplyRemoteChange with different file type should be handled as |
| 580 // with wrong file type will result in error. | 580 // overwrite. |
| 581 change = | |
| 582 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, SYNC_FILE_TYPE_FILE); | |
| 583 EXPECT_EQ(SYNC_STATUS_OK, | |
| 584 ApplyRemoteChange(file_system.file_system_context(), | |
| 585 change, | |
| 586 kFilePath1, | |
| 587 kDir, | |
| 588 SYNC_FILE_TYPE_DIRECTORY)); | |
|
kinuko
2013/04/30 13:31:09
Can we check FileExists(kDir) here?
tzik
2013/04/30 13:54:40
Done.
| |
| 581 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 589 change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 582 SYNC_FILE_TYPE_FILE); | 590 SYNC_FILE_TYPE_DIRECTORY); |
| 583 EXPECT_NE(SYNC_STATUS_OK, | 591 EXPECT_EQ(SYNC_STATUS_OK, |
| 584 ApplyRemoteChange(file_system.file_system_context(), | 592 ApplyRemoteChange(file_system.file_system_context(), |
| 585 change, kFilePath1, kDir, | 593 change, |
| 586 SYNC_FILE_TYPE_DIRECTORY)); | 594 kFilePath1, |
| 595 kDir, | |
| 596 SYNC_FILE_TYPE_FILE)); | |
| 587 | 597 |
| 588 // Creating a file/directory must have increased the usage more than | 598 // Creating a file/directory must have increased the usage more than |
| 589 // the size of kTestFileData2. | 599 // the size of kTestFileData2. |
| 590 new_usage = usage; | 600 new_usage = usage; |
| 591 EXPECT_EQ(quota::kQuotaStatusOk, | 601 EXPECT_EQ(quota::kQuotaStatusOk, |
| 592 file_system.GetUsageAndQuota(&new_usage, "a)); | 602 file_system.GetUsageAndQuota(&new_usage, "a)); |
| 593 EXPECT_GT(new_usage, | 603 EXPECT_GT(new_usage, |
| 594 static_cast<int64>(usage + arraysize(kTestFileData2) - 1)); | 604 static_cast<int64>(usage + arraysize(kTestFileData2) - 1)); |
| 595 | 605 |
| 596 // The changes applied by ApplyRemoteChange should not be recorded in | 606 // The changes applied by ApplyRemoteChange should not be recorded in |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 | 663 |
| 654 // Make sure kDir and kFile are created by ApplyRemoteChange. | 664 // Make sure kDir and kFile are created by ApplyRemoteChange. |
| 655 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.FileExists(kFile)); | 665 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.FileExists(kFile)); |
| 656 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.DirectoryExists(kDir)); | 666 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.DirectoryExists(kDir)); |
| 657 | 667 |
| 658 sync_context_->ShutdownOnUIThread(); | 668 sync_context_->ShutdownOnUIThread(); |
| 659 file_system.TearDown(); | 669 file_system.TearDown(); |
| 660 } | 670 } |
| 661 | 671 |
| 662 } // namespace sync_file_system | 672 } // namespace sync_file_system |
| OLD | NEW |