| 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 "chrome/browser/chromeos/drive/resource_metadata.h" | 5 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 EXPECT_EQ(FILE_ERROR_NOT_FOUND, resource_metadata_->GetResourceEntryByPath( | 413 EXPECT_EQ(FILE_ERROR_NOT_FOUND, resource_metadata_->GetResourceEntryByPath( |
| 414 base::FilePath::FromUTF8Unsafe("drive/root/dir2"), &entry)); | 414 base::FilePath::FromUTF8Unsafe("drive/root/dir2"), &entry)); |
| 415 | 415 |
| 416 // Make sure that directory cannot move under a file. | 416 // Make sure that directory cannot move under a file. |
| 417 dir_entry.set_parent_local_id(file_id); | 417 dir_entry.set_parent_local_id(file_id); |
| 418 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, | 418 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, |
| 419 resource_metadata_->RefreshEntry(dir_entry)); | 419 resource_metadata_->RefreshEntry(dir_entry)); |
| 420 | 420 |
| 421 // Cannot refresh root. | 421 // Cannot refresh root. |
| 422 dir_entry.Clear(); | 422 dir_entry.Clear(); |
| 423 dir_entry.set_resource_id(util::kDriveGrandRootLocalId); | |
| 424 dir_entry.set_local_id(util::kDriveGrandRootLocalId); | 423 dir_entry.set_local_id(util::kDriveGrandRootLocalId); |
| 425 dir_entry.set_title("new-root-name"); | 424 dir_entry.set_title("new-root-name"); |
| 426 dir_entry.set_parent_local_id(dir3_id); | 425 dir_entry.set_parent_local_id(dir3_id); |
| 427 EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, | 426 EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, |
| 428 resource_metadata_->RefreshEntry(dir_entry)); | 427 resource_metadata_->RefreshEntry(dir_entry)); |
| 429 } | 428 } |
| 430 | 429 |
| 431 TEST_F(ResourceMetadataTest, GetSubDirectoriesRecursively) { | 430 TEST_F(ResourceMetadataTest, GetSubDirectoriesRecursively) { |
| 432 std::set<base::FilePath> sub_directories; | 431 std::set<base::FilePath> sub_directories; |
| 433 | 432 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 // change stamp should be reset. | 718 // change stamp should be reset. |
| 720 EXPECT_EQ(0, resource_metadata_->GetLargestChangestamp()); | 719 EXPECT_EQ(0, resource_metadata_->GetLargestChangestamp()); |
| 721 | 720 |
| 722 // root should continue to exist. | 721 // root should continue to exist. |
| 723 ResourceEntry entry; | 722 ResourceEntry entry; |
| 724 ASSERT_EQ(FILE_ERROR_OK, | 723 ASSERT_EQ(FILE_ERROR_OK, |
| 725 resource_metadata_->GetResourceEntryByPath( | 724 resource_metadata_->GetResourceEntryByPath( |
| 726 base::FilePath::FromUTF8Unsafe("drive"), &entry)); | 725 base::FilePath::FromUTF8Unsafe("drive"), &entry)); |
| 727 EXPECT_EQ("drive", entry.base_name()); | 726 EXPECT_EQ("drive", entry.base_name()); |
| 728 ASSERT_TRUE(entry.file_info().is_directory()); | 727 ASSERT_TRUE(entry.file_info().is_directory()); |
| 729 EXPECT_EQ(util::kDriveGrandRootLocalId, entry.resource_id()); | 728 EXPECT_EQ(util::kDriveGrandRootLocalId, entry.local_id()); |
| 730 | 729 |
| 731 // There are "other" and "trash" under "drive". | 730 // There are "other" and "trash" under "drive". |
| 732 ASSERT_EQ(FILE_ERROR_OK, | 731 ASSERT_EQ(FILE_ERROR_OK, |
| 733 resource_metadata_->ReadDirectoryByPath( | 732 resource_metadata_->ReadDirectoryByPath( |
| 734 base::FilePath::FromUTF8Unsafe("drive"), &entries)); | 733 base::FilePath::FromUTF8Unsafe("drive"), &entries)); |
| 735 EXPECT_EQ(2U, entries.size()); | 734 EXPECT_EQ(2U, entries.size()); |
| 736 | 735 |
| 737 // The "other" directory should be empty. | 736 // The "other" directory should be empty. |
| 738 ASSERT_EQ(FILE_ERROR_OK, | 737 ASSERT_EQ(FILE_ERROR_OK, |
| 739 resource_metadata_->ReadDirectoryByPath( | 738 resource_metadata_->ReadDirectoryByPath( |
| 740 base::FilePath::FromUTF8Unsafe("drive/other"), &entries)); | 739 base::FilePath::FromUTF8Unsafe("drive/other"), &entries)); |
| 741 EXPECT_TRUE(entries.empty()); | 740 EXPECT_TRUE(entries.empty()); |
| 742 | 741 |
| 743 // The "trash" directory should be empty. | 742 // The "trash" directory should be empty. |
| 744 ASSERT_EQ(FILE_ERROR_OK, | 743 ASSERT_EQ(FILE_ERROR_OK, |
| 745 resource_metadata_->ReadDirectoryByPath( | 744 resource_metadata_->ReadDirectoryByPath( |
| 746 base::FilePath::FromUTF8Unsafe("drive/trash"), &entries)); | 745 base::FilePath::FromUTF8Unsafe("drive/trash"), &entries)); |
| 747 EXPECT_TRUE(entries.empty()); | 746 EXPECT_TRUE(entries.empty()); |
| 748 } | 747 } |
| 749 | 748 |
| 750 } // namespace internal | 749 } // namespace internal |
| 751 } // namespace drive | 750 } // namespace drive |
| OLD | NEW |