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

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: Fix for comments 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // Sets the changestamp to 654321, equal to that of "account_metadata.json" 604 // 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. 605 // test data, indicating the cache is holding the latest file system info.
602 void SaveTestFileSystem() { 606 void SaveTestFileSystem() {
603 DriveRootDirectoryProto root; 607 DriveRootDirectoryProto root;
604 root.set_version(kProtoVersion); 608 root.set_version(kProtoVersion);
605 root.set_largest_changestamp(654321); 609 root.set_largest_changestamp(654321);
606 DriveDirectoryProto* root_dir = root.mutable_drive_directory(); 610 DriveDirectoryProto* root_dir = root.mutable_drive_directory();
607 DriveEntryProto* dir_base = root_dir->mutable_drive_entry(); 611 DriveEntryProto* dir_base = root_dir->mutable_drive_entry();
608 PlatformFileInfoProto* platform_info = dir_base->mutable_file_info(); 612 PlatformFileInfoProto* platform_info = dir_base->mutable_file_info();
609 dir_base->set_title("drive"); 613 dir_base->set_title("drive");
610 dir_base->set_resource_id(kDriveRootDirectoryResourceId); 614 dir_base->set_resource_id(kTestRootDirectoryResourceId);
611 dir_base->set_upload_url("http://resumable-create-media/1"); 615 dir_base->set_upload_url("http://resumable-create-media/1");
612 platform_info->set_is_directory(true); 616 platform_info->set_is_directory(true);
613 617
614 // drive/File1 618 // drive/File1
615 DriveEntryProto* file = root_dir->add_child_files(); 619 DriveEntryProto* file = root_dir->add_child_files();
616 file->set_title("File1"); 620 file->set_title("File1");
617 file->set_resource_id("resource_id:File1"); 621 file->set_resource_id("resource_id:File1");
618 file->set_upload_url("http://resumable-edit-media/1"); 622 file->set_upload_url("http://resumable-edit-media/1");
619 file->mutable_file_specific_info()->set_file_md5("md5"); 623 file->mutable_file_specific_info()->set_file_md5("md5");
620 platform_info = file->mutable_file_info(); 624 platform_info = file->mutable_file_info();
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 EXPECT_EQ(2, counter); 852 EXPECT_EQ(2, counter);
849 } 853 }
850 854
851 TEST_F(DriveFileSystemTest, SearchRootDirectory) { 855 TEST_F(DriveFileSystemTest, SearchRootDirectory) {
852 LoadRootFeedDocument("gdata/root_feed.json"); 856 LoadRootFeedDocument("gdata/root_feed.json");
853 857
854 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("drive")); 858 const FilePath kFilePath = FilePath(FILE_PATH_LITERAL("drive"));
855 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync( 859 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(
856 FilePath(FILE_PATH_LITERAL(kFilePath))); 860 FilePath(FILE_PATH_LITERAL(kFilePath)));
857 ASSERT_TRUE(entry.get()); 861 ASSERT_TRUE(entry.get());
858 EXPECT_EQ(kDriveRootDirectoryResourceId, entry->resource_id()); 862 // We get kWAPIRootDirectoryResourceId instead of kTestRootDirectoryResourceId
863 // here, as the root ID is set in DriveFeedLoader::UpdateFromFeed().
864 EXPECT_EQ(kWAPIRootDirectoryResourceId, entry->resource_id());
859 } 865 }
860 866
861 TEST_F(DriveFileSystemTest, SearchExistingFile) { 867 TEST_F(DriveFileSystemTest, SearchExistingFile) {
862 LoadRootFeedDocument("gdata/root_feed.json"); 868 LoadRootFeedDocument("gdata/root_feed.json");
863 869
864 const FilePath kFilePath = FilePath( 870 const FilePath kFilePath = FilePath(
865 FILE_PATH_LITERAL("drive/File 1.txt")); 871 FILE_PATH_LITERAL("drive/File 1.txt"));
866 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); 872 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath);
867 ASSERT_TRUE(entry.get()); 873 ASSERT_TRUE(entry.get());
868 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); 874 EXPECT_EQ("file:2_file_resource_id", entry->resource_id());
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 file_system_->GetAvailableSpace(callback); 2514 file_system_->GetAvailableSpace(callback);
2509 google_apis::test_util::RunBlockingPoolTask(); 2515 google_apis::test_util::RunBlockingPoolTask();
2510 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_); 2516 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_);
2511 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_); 2517 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_);
2512 } 2518 }
2513 2519
2514 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) { 2520 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) {
2515 LoadRootFeedDocument("gdata/root_feed.json"); 2521 LoadRootFeedDocument("gdata/root_feed.json");
2516 2522
2517 // We'll fetch documents in the root directory with its resource ID. 2523 // We'll fetch documents in the root directory with its resource ID.
2524 // kWAPIRootDirectoryResourceId instead of kTestRootDirectoryResourceId
2525 // is used here as the root ID is set in DriveFeedLoader::UpdateFromFeed().
2518 EXPECT_CALL(*mock_drive_service_, 2526 EXPECT_CALL(*mock_drive_service_,
2519 GetDocuments(Eq(GURL()), _, _, kDriveRootDirectoryResourceId, _)) 2527 GetDocuments(Eq(GURL()), _, _, kWAPIRootDirectoryResourceId, _))
2520 .Times(1); 2528 .Times(1);
2521 // We'll notify the directory change to the observer. 2529 // We'll notify the directory change to the observer.
2522 EXPECT_CALL(*mock_directory_observer_, 2530 EXPECT_CALL(*mock_directory_observer_,
2523 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1); 2531 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1);
2524 2532
2525 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory)); 2533 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory));
2526 google_apis::test_util::RunBlockingPoolTask(); 2534 google_apis::test_util::RunBlockingPoolTask();
2527 } 2535 }
2528 2536
2529 TEST_F(DriveFileSystemTest, OpenAndCloseFile) { 2537 TEST_F(DriveFileSystemTest, OpenAndCloseFile) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 2619
2612 // Try to close the same file twice. 2620 // Try to close the same file twice.
2613 file_system_->CloseFile(kFileInRoot, close_file_callback); 2621 file_system_->CloseFile(kFileInRoot, close_file_callback);
2614 message_loop_.Run(); 2622 message_loop_.Run();
2615 2623
2616 // It must fail. 2624 // It must fail.
2617 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2625 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2618 } 2626 }
2619 2627
2620 } // namespace drive 2628 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698