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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 | 593 |
594 int file_count = 0, directory_count = 0; | 594 int file_count = 0, directory_count = 0; |
595 for (; !it->IsAtEnd(); it->Advance()) { | 595 for (; !it->IsAtEnd(); it->Advance()) { |
596 if (!it->GetValue().file_info().is_directory()) | 596 if (!it->GetValue().file_info().is_directory()) |
597 ++file_count; | 597 ++file_count; |
598 else | 598 else |
599 ++directory_count; | 599 ++directory_count; |
600 } | 600 } |
601 | 601 |
602 EXPECT_EQ(7, file_count); | 602 EXPECT_EQ(7, file_count); |
603 EXPECT_EQ(6, directory_count); | 603 EXPECT_EQ(7, directory_count); |
604 } | 604 } |
605 | 605 |
606 TEST_F(ResourceMetadataTest, DuplicatedNames) { | 606 TEST_F(ResourceMetadataTest, DuplicatedNames) { |
607 std::string root_local_id; | 607 std::string root_local_id; |
608 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->GetIdByPath( | 608 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->GetIdByPath( |
609 base::FilePath::FromUTF8Unsafe("drive/root"), &root_local_id)); | 609 base::FilePath::FromUTF8Unsafe("drive/root"), &root_local_id)); |
610 | 610 |
611 ResourceEntry entry; | 611 ResourceEntry entry; |
612 | 612 |
613 // When multiple entries with the same title are added in a single directory, | 613 // When multiple entries with the same title are added in a single directory, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 721 |
722 // root should continue to exist. | 722 // root should continue to exist. |
723 ResourceEntry entry; | 723 ResourceEntry entry; |
724 ASSERT_EQ(FILE_ERROR_OK, | 724 ASSERT_EQ(FILE_ERROR_OK, |
725 resource_metadata_->GetResourceEntryByPath( | 725 resource_metadata_->GetResourceEntryByPath( |
726 base::FilePath::FromUTF8Unsafe("drive"), &entry)); | 726 base::FilePath::FromUTF8Unsafe("drive"), &entry)); |
727 EXPECT_EQ("drive", entry.base_name()); | 727 EXPECT_EQ("drive", entry.base_name()); |
728 ASSERT_TRUE(entry.file_info().is_directory()); | 728 ASSERT_TRUE(entry.file_info().is_directory()); |
729 EXPECT_EQ(util::kDriveGrandRootLocalId, entry.resource_id()); | 729 EXPECT_EQ(util::kDriveGrandRootLocalId, entry.resource_id()); |
730 | 730 |
731 // There is "other" under "drive". | 731 // There is "other" and "trash" under "drive". |
732 ASSERT_EQ(FILE_ERROR_OK, | 732 ASSERT_EQ(FILE_ERROR_OK, |
733 resource_metadata_->ReadDirectoryByPath( | 733 resource_metadata_->ReadDirectoryByPath( |
734 base::FilePath::FromUTF8Unsafe("drive"), &entries)); | 734 base::FilePath::FromUTF8Unsafe("drive"), &entries)); |
735 EXPECT_EQ(1U, entries.size()); | 735 EXPECT_EQ(2U, entries.size()); |
736 | 736 |
737 // The "other" directory should be empty. | 737 // The "other" directory should be empty. |
738 ASSERT_EQ(FILE_ERROR_OK, | 738 ASSERT_EQ(FILE_ERROR_OK, |
739 resource_metadata_->ReadDirectoryByPath( | 739 resource_metadata_->ReadDirectoryByPath( |
740 base::FilePath::FromUTF8Unsafe("drive/other"), &entries)); | 740 base::FilePath::FromUTF8Unsafe("drive/other"), &entries)); |
741 EXPECT_TRUE(entries.empty()); | 741 EXPECT_TRUE(entries.empty()); |
| 742 |
| 743 // The "trash" directory should be empty. |
| 744 ASSERT_EQ(FILE_ERROR_OK, |
| 745 resource_metadata_->ReadDirectoryByPath( |
| 746 base::FilePath::FromUTF8Unsafe("drive/trash"), &entries)); |
| 747 EXPECT_TRUE(entries.empty()); |
742 } | 748 } |
743 | 749 |
744 } // namespace internal | 750 } // namespace internal |
745 } // namespace drive | 751 } // namespace drive |
OLD | NEW |