| 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_file_system.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 // Sets the changestamp to 654321, equal to that of "account_metadata.json" | 600 // Sets the changestamp to 654321, equal to that of "account_metadata.json" |
| 601 // test data, indicating the cache is holding the latest file system info. | 601 // test data, indicating the cache is holding the latest file system info. |
| 602 void SaveTestFileSystem() { | 602 void SaveTestFileSystem() { |
| 603 DriveRootDirectoryProto root; | 603 DriveRootDirectoryProto root; |
| 604 root.set_version(kProtoVersion); | 604 root.set_version(kProtoVersion); |
| 605 root.set_largest_changestamp(654321); | 605 root.set_largest_changestamp(654321); |
| 606 DriveDirectoryProto* root_dir = root.mutable_drive_directory(); | 606 DriveDirectoryProto* root_dir = root.mutable_drive_directory(); |
| 607 DriveEntryProto* dir_base = root_dir->mutable_drive_entry(); | 607 DriveEntryProto* dir_base = root_dir->mutable_drive_entry(); |
| 608 PlatformFileInfoProto* platform_info = dir_base->mutable_file_info(); | 608 PlatformFileInfoProto* platform_info = dir_base->mutable_file_info(); |
| 609 dir_base->set_title("drive"); | 609 dir_base->set_title("drive"); |
| 610 dir_base->set_resource_id(kDriveRootDirectoryResourceId); | 610 dir_base->set_resource_id(kWAPIRootDirectoryResourceId); |
| 611 dir_base->set_upload_url("http://resumable-create-media/1"); | 611 dir_base->set_upload_url("http://resumable-create-media/1"); |
| 612 platform_info->set_is_directory(true); | 612 platform_info->set_is_directory(true); |
| 613 | 613 |
| 614 // drive/File1 | 614 // drive/File1 |
| 615 DriveEntryProto* file = root_dir->add_child_files(); | 615 DriveEntryProto* file = root_dir->add_child_files(); |
| 616 file->set_title("File1"); | 616 file->set_title("File1"); |
| 617 file->set_resource_id("resource_id:File1"); | 617 file->set_resource_id("resource_id:File1"); |
| 618 file->set_upload_url("http://resumable-edit-media/1"); | 618 file->set_upload_url("http://resumable-edit-media/1"); |
| 619 file->mutable_file_specific_info()->set_file_md5("md5"); | 619 file->mutable_file_specific_info()->set_file_md5("md5"); |
| 620 platform_info = file->mutable_file_info(); | 620 platform_info = file->mutable_file_info(); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 EXPECT_EQ(2, counter); | 848 EXPECT_EQ(2, counter); |
| 849 } | 849 } |
| 850 | 850 |
| 851 TEST_F(DriveFileSystemTest, SearchRootDirectory) { | 851 TEST_F(DriveFileSystemTest, SearchRootDirectory) { |
| 852 LoadRootFeedDocument("gdata/root_feed.json"); | 852 LoadRootFeedDocument("gdata/root_feed.json"); |
| 853 | 853 |
| 854 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("drive")); | 854 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("drive")); |
| 855 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync( | 855 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync( |
| 856 FilePath(FILE_PATH_LITERAL(kFilePath))); | 856 FilePath(FILE_PATH_LITERAL(kFilePath))); |
| 857 ASSERT_TRUE(entry.get()); | 857 ASSERT_TRUE(entry.get()); |
| 858 EXPECT_EQ(kDriveRootDirectoryResourceId, entry->resource_id()); | 858 EXPECT_EQ(kWAPIRootDirectoryResourceId, entry->resource_id()); |
| 859 } | 859 } |
| 860 | 860 |
| 861 TEST_F(DriveFileSystemTest, SearchExistingFile) { | 861 TEST_F(DriveFileSystemTest, SearchExistingFile) { |
| 862 LoadRootFeedDocument("gdata/root_feed.json"); | 862 LoadRootFeedDocument("gdata/root_feed.json"); |
| 863 | 863 |
| 864 const FilePath kFilePath = FilePath( | 864 const FilePath kFilePath = FilePath( |
| 865 FILE_PATH_LITERAL("drive/File 1.txt")); | 865 FILE_PATH_LITERAL("drive/File 1.txt")); |
| 866 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); | 866 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| 867 ASSERT_TRUE(entry.get()); | 867 ASSERT_TRUE(entry.get()); |
| 868 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); | 868 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); |
| (...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2509 google_apis::test_util::RunBlockingPoolTask(); | 2509 google_apis::test_util::RunBlockingPoolTask(); |
| 2510 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_); | 2510 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_); |
| 2511 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_); | 2511 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_); |
| 2512 } | 2512 } |
| 2513 | 2513 |
| 2514 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) { | 2514 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) { |
| 2515 LoadRootFeedDocument("gdata/root_feed.json"); | 2515 LoadRootFeedDocument("gdata/root_feed.json"); |
| 2516 | 2516 |
| 2517 // We'll fetch documents in the root directory with its resource ID. | 2517 // We'll fetch documents in the root directory with its resource ID. |
| 2518 EXPECT_CALL(*mock_drive_service_, | 2518 EXPECT_CALL(*mock_drive_service_, |
| 2519 GetDocuments(Eq(GURL()), _, _, kDriveRootDirectoryResourceId, _)) | 2519 GetDocuments(Eq(GURL()), _, _, kWAPIRootDirectoryResourceId, _)) |
| 2520 .Times(1); | 2520 .Times(1); |
| 2521 // We'll notify the directory change to the observer. | 2521 // We'll notify the directory change to the observer. |
| 2522 EXPECT_CALL(*mock_directory_observer_, | 2522 EXPECT_CALL(*mock_directory_observer_, |
| 2523 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1); | 2523 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1); |
| 2524 | 2524 |
| 2525 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory)); | 2525 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory)); |
| 2526 google_apis::test_util::RunBlockingPoolTask(); | 2526 google_apis::test_util::RunBlockingPoolTask(); |
| 2527 } | 2527 } |
| 2528 | 2528 |
| 2529 TEST_F(DriveFileSystemTest, OpenAndCloseFile) { | 2529 TEST_F(DriveFileSystemTest, OpenAndCloseFile) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 | 2611 |
| 2612 // Try to close the same file twice. | 2612 // Try to close the same file twice. |
| 2613 file_system_->CloseFile(kFileInRoot, close_file_callback); | 2613 file_system_->CloseFile(kFileInRoot, close_file_callback); |
| 2614 message_loop_.Run(); | 2614 message_loop_.Run(); |
| 2615 | 2615 |
| 2616 // It must fail. | 2616 // It must fail. |
| 2617 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2617 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
| 2618 } | 2618 } |
| 2619 | 2619 |
| 2620 } // namespace drive | 2620 } // namespace drive |
| OLD | NEW |