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

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

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