| 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/drive_resource_metadata.h" | 5 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 proto.set_version(kProtoVersion + 1); | 160 proto.set_version(kProtoVersion + 1); |
| 161 ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); | 161 ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
| 162 // This should fail as the version is newer. | 162 // This should fail as the version is newer. |
| 163 ASSERT_FALSE(resource_metadata.ParseFromString(serialized_proto)); | 163 ASSERT_FALSE(resource_metadata.ParseFromString(serialized_proto)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 TEST_F(DriveResourceMetadataTest, GetEntryByResourceId_RootDirectory) { | 166 TEST_F(DriveResourceMetadataTest, GetEntryByResourceId_RootDirectory) { |
| 167 DriveResourceMetadata resource_metadata; | 167 DriveResourceMetadata resource_metadata; |
| 168 // Look up the root directory by its resource ID. | 168 // Look up the root directory by its resource ID. |
| 169 DriveEntry* entry = resource_metadata.GetEntryByResourceId( | 169 DriveEntry* entry = resource_metadata.GetEntryByResourceId( |
| 170 kDriveRootDirectoryResourceId); | 170 resource_metadata.root_resource_id()); |
| 171 ASSERT_TRUE(entry); | 171 ASSERT_TRUE(entry); |
| 172 EXPECT_EQ(kDriveRootDirectoryResourceId, entry->resource_id()); | 172 EXPECT_EQ(resource_metadata.root_resource_id(), entry->resource_id()); |
| 173 } | 173 } |
| 174 | 174 |
| 175 TEST_F(DriveResourceMetadataTest, GetEntryInfoByResourceId) { | 175 TEST_F(DriveResourceMetadataTest, GetEntryInfoByResourceId) { |
| 176 // Confirm that an existing file is found. | 176 // Confirm that an existing file is found. |
| 177 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 177 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 178 FilePath drive_file_path; | 178 FilePath drive_file_path; |
| 179 scoped_ptr<DriveEntryProto> entry_proto; | 179 scoped_ptr<DriveEntryProto> entry_proto; |
| 180 resource_metadata_.GetEntryInfoByResourceId( | 180 resource_metadata_.GetEntryInfoByResourceId( |
| 181 "file_resource_id:file4", | 181 "file_resource_id:file4", |
| 182 base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback, | 182 base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback, |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // Remove unknown resource_id using RemoveEntryFromParent. | 444 // Remove unknown resource_id using RemoveEntryFromParent. |
| 445 resource_metadata_.RemoveEntryFromParent( | 445 resource_metadata_.RemoveEntryFromParent( |
| 446 "foo", | 446 "foo", |
| 447 base::Bind(&test_util::CopyResultsFromFileMoveCallback, | 447 base::Bind(&test_util::CopyResultsFromFileMoveCallback, |
| 448 &error, &drive_file_path)); | 448 &error, &drive_file_path)); |
| 449 gdata::test_util::RunBlockingPoolTask(); | 449 gdata::test_util::RunBlockingPoolTask(); |
| 450 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); | 450 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); |
| 451 | 451 |
| 452 // Try removing root. This should fail. | 452 // Try removing root. This should fail. |
| 453 resource_metadata_.RemoveEntryFromParent( | 453 resource_metadata_.RemoveEntryFromParent( |
| 454 kDriveRootDirectoryResourceId, | 454 resource_metadata_.root_resource_id(), |
| 455 base::Bind(&test_util::CopyResultsFromFileMoveCallback, | 455 base::Bind(&test_util::CopyResultsFromFileMoveCallback, |
| 456 &error, &drive_file_path)); | 456 &error, &drive_file_path)); |
| 457 gdata::test_util::RunBlockingPoolTask(); | 457 gdata::test_util::RunBlockingPoolTask(); |
| 458 EXPECT_EQ(DRIVE_FILE_ERROR_ACCESS_DENIED, error); | 458 EXPECT_EQ(DRIVE_FILE_ERROR_ACCESS_DENIED, error); |
| 459 } | 459 } |
| 460 | 460 |
| 461 TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { | 461 TEST_F(DriveResourceMetadataTest, MoveEntryToDirectory) { |
| 462 DriveFileError error = DRIVE_FILE_ERROR_FAILED; | 462 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| 463 FilePath drive_file_path; | 463 FilePath drive_file_path; |
| 464 scoped_ptr<DriveEntryProto> entry_proto; | 464 scoped_ptr<DriveEntryProto> entry_proto; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 FilePath::FromUTF8Unsafe("drive/dir2/file11"), | 591 FilePath::FromUTF8Unsafe("drive/dir2/file11"), |
| 592 "file11", | 592 "file11", |
| 593 base::Bind(&test_util::CopyResultsFromFileMoveCallback, | 593 base::Bind(&test_util::CopyResultsFromFileMoveCallback, |
| 594 &error, &drive_file_path)); | 594 &error, &drive_file_path)); |
| 595 gdata::test_util::RunBlockingPoolTask(); | 595 gdata::test_util::RunBlockingPoolTask(); |
| 596 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); | 596 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); |
| 597 EXPECT_EQ(FilePath(), drive_file_path); | 597 EXPECT_EQ(FilePath(), drive_file_path); |
| 598 } | 598 } |
| 599 | 599 |
| 600 } // namespace drive | 600 } // namespace drive |
| OLD | NEW |