Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/browser/chromeos/drive/drive_file_system_unittest.cc

Issue 11348030: Revert 164876 - Set root resource ID upon full feed update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 using ::testing::AtLeast; 42 using ::testing::AtLeast;
43 using ::testing::Eq; 43 using ::testing::Eq;
44 using ::testing::NotNull; 44 using ::testing::NotNull;
45 using ::testing::Return; 45 using ::testing::Return;
46 using ::testing::StrictMock; 46 using ::testing::StrictMock;
47 using ::testing::_; 47 using ::testing::_;
48 48
49 namespace drive { 49 namespace drive {
50 namespace { 50 namespace {
51 51
52 // The root directory resource ID for WAPI.
53 // TODO(haruki): Make Drive API equivalent work. http://crbug.com/157114
54 const char kTestRootDirectoryResourceId[] = "folder:testroot";
55
56 const char kSymLinkToDevNull[] = "/dev/null"; 52 const char kSymLinkToDevNull[] = "/dev/null";
57 53
58 const int64 kLotsOfSpace = kMinFreeSpace * 10; 54 const int64 kLotsOfSpace = kMinFreeSpace * 10;
59 55
60 struct SearchResultPair { 56 struct SearchResultPair {
61 const char* path; 57 const char* path;
62 const bool is_directory; 58 const bool is_directory;
63 }; 59 };
64 60
65 // Callback to DriveFileSystem::Search used in ContentSearch tests. 61 // Callback to DriveFileSystem::Search used in ContentSearch tests.
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 // equal to that of "account_metadata.json" test data, indicating the cache is 620 // equal to that of "account_metadata.json" test data, indicating the cache is
625 // holding the latest file system info. 621 // holding the latest file system info.
626 void SaveTestFileSystem(SaveTestFileSystemParam param) { 622 void SaveTestFileSystem(SaveTestFileSystemParam param) {
627 DriveRootDirectoryProto root; 623 DriveRootDirectoryProto root;
628 root.set_version(kProtoVersion); 624 root.set_version(kProtoVersion);
629 root.set_largest_changestamp(param == USE_SERVER_TIMESTAMP ? 654321 : 1); 625 root.set_largest_changestamp(param == USE_SERVER_TIMESTAMP ? 654321 : 1);
630 DriveDirectoryProto* root_dir = root.mutable_drive_directory(); 626 DriveDirectoryProto* root_dir = root.mutable_drive_directory();
631 DriveEntryProto* dir_base = root_dir->mutable_drive_entry(); 627 DriveEntryProto* dir_base = root_dir->mutable_drive_entry();
632 PlatformFileInfoProto* platform_info = dir_base->mutable_file_info(); 628 PlatformFileInfoProto* platform_info = dir_base->mutable_file_info();
633 dir_base->set_title("drive"); 629 dir_base->set_title("drive");
634 dir_base->set_resource_id(kTestRootDirectoryResourceId); 630 dir_base->set_resource_id(kDriveRootDirectoryResourceId);
635 dir_base->set_upload_url("http://resumable-create-media/1"); 631 dir_base->set_upload_url("http://resumable-create-media/1");
636 platform_info->set_is_directory(true); 632 platform_info->set_is_directory(true);
637 633
638 // drive/File1 634 // drive/File1
639 DriveEntryProto* file = root_dir->add_child_files(); 635 DriveEntryProto* file = root_dir->add_child_files();
640 file->set_title("File1"); 636 file->set_title("File1");
641 file->set_resource_id("resource_id:File1"); 637 file->set_resource_id("resource_id:File1");
642 file->set_upload_url("http://resumable-edit-media/1"); 638 file->set_upload_url("http://resumable-edit-media/1");
643 file->mutable_file_specific_info()->set_file_md5("md5"); 639 file->mutable_file_specific_info()->set_file_md5("md5");
644 platform_info = file->mutable_file_info(); 640 platform_info = file->mutable_file_info();
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 EXPECT_EQ(2, counter); 868 EXPECT_EQ(2, counter);
873 } 869 }
874 870
875 TEST_F(DriveFileSystemTest, SearchRootDirectory) { 871 TEST_F(DriveFileSystemTest, SearchRootDirectory) {
876 LoadRootFeedDocument("gdata/root_feed.json"); 872 LoadRootFeedDocument("gdata/root_feed.json");
877 873
878 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("drive")); 874 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("drive"));
879 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync( 875 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(
880 FilePath(FILE_PATH_LITERAL(kFilePath))); 876 FilePath(FILE_PATH_LITERAL(kFilePath)));
881 ASSERT_TRUE(entry.get()); 877 ASSERT_TRUE(entry.get());
882 // We get kWAPIRootDirectoryResourceId instead of kTestRootDirectoryResourceId 878 EXPECT_EQ(kDriveRootDirectoryResourceId, entry->resource_id());
883 // here, as the root ID is set in DriveFeedLoader::UpdateFromFeed().
884 EXPECT_EQ(kWAPIRootDirectoryResourceId, entry->resource_id());
885 } 879 }
886 880
887 TEST_F(DriveFileSystemTest, SearchExistingFile) { 881 TEST_F(DriveFileSystemTest, SearchExistingFile) {
888 LoadRootFeedDocument("gdata/root_feed.json"); 882 LoadRootFeedDocument("gdata/root_feed.json");
889 883
890 const FilePath kFilePath = FilePath( 884 const FilePath kFilePath = FilePath(
891 FILE_PATH_LITERAL("drive/File 1.txt")); 885 FILE_PATH_LITERAL("drive/File 1.txt"));
892 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); 886 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath);
893 ASSERT_TRUE(entry.get()); 887 ASSERT_TRUE(entry.get());
894 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); 888 EXPECT_EQ("file:2_file_resource_id", entry->resource_id());
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 file_system_->GetAvailableSpace(callback); 2570 file_system_->GetAvailableSpace(callback);
2577 google_apis::test_util::RunBlockingPoolTask(); 2571 google_apis::test_util::RunBlockingPoolTask();
2578 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_); 2572 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_);
2579 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_); 2573 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_);
2580 } 2574 }
2581 2575
2582 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) { 2576 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) {
2583 LoadRootFeedDocument("gdata/root_feed.json"); 2577 LoadRootFeedDocument("gdata/root_feed.json");
2584 2578
2585 // We'll fetch documents in the root directory with its resource ID. 2579 // We'll fetch documents in the root directory with its resource ID.
2586 // kWAPIRootDirectoryResourceId instead of kTestRootDirectoryResourceId
2587 // is used here as the root ID is set in DriveFeedLoader::UpdateFromFeed().
2588 EXPECT_CALL(*mock_drive_service_, 2580 EXPECT_CALL(*mock_drive_service_,
2589 GetDocuments(Eq(GURL()), _, _, kWAPIRootDirectoryResourceId, _)) 2581 GetDocuments(Eq(GURL()), _, _, kDriveRootDirectoryResourceId, _))
2590 .Times(1); 2582 .Times(1);
2591 // We'll notify the directory change to the observer. 2583 // We'll notify the directory change to the observer.
2592 EXPECT_CALL(*mock_directory_observer_, 2584 EXPECT_CALL(*mock_directory_observer_,
2593 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1); 2585 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1);
2594 2586
2595 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory)); 2587 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory));
2596 google_apis::test_util::RunBlockingPoolTask(); 2588 google_apis::test_util::RunBlockingPoolTask();
2597 } 2589 }
2598 2590
2599 TEST_F(DriveFileSystemTest, OpenAndCloseFile) { 2591 TEST_F(DriveFileSystemTest, OpenAndCloseFile) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 2673
2682 // Try to close the same file twice. 2674 // Try to close the same file twice.
2683 file_system_->CloseFile(kFileInRoot, close_file_callback); 2675 file_system_->CloseFile(kFileInRoot, close_file_callback);
2684 message_loop_.Run(); 2676 message_loop_.Run();
2685 2677
2686 // It must fail. 2678 // It must fail.
2687 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2679 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2688 } 2680 }
2689 2681
2690 } // namespace drive 2682 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_feed_loader.cc ('k') | chrome/browser/chromeos/drive/drive_resource_metadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698