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

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: Add a comment. Created 8 years, 2 months 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 kWAPIRootDirectoryResourceId[] = "folder:root";
satorux1 2012/10/23 06:54:50 I think it's better to keep the constant in drive_
kochi 2012/10/23 07:44:35 Done.
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(kWAPIRootDirectoryResourceId);
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 EXPECT_EQ(kWAPIRootDirectoryResourceId, entry->resource_id());
859 } 863 }
860 864
861 TEST_F(DriveFileSystemTest, SearchExistingFile) { 865 TEST_F(DriveFileSystemTest, SearchExistingFile) {
862 LoadRootFeedDocument("gdata/root_feed.json"); 866 LoadRootFeedDocument("gdata/root_feed.json");
863 867
864 const FilePath kFilePath = FilePath( 868 const FilePath kFilePath = FilePath(
865 FILE_PATH_LITERAL("drive/File 1.txt")); 869 FILE_PATH_LITERAL("drive/File 1.txt"));
866 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); 870 scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath);
867 ASSERT_TRUE(entry.get()); 871 ASSERT_TRUE(entry.get());
868 EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); 872 EXPECT_EQ("file:2_file_resource_id", entry->resource_id());
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 google_apis::test_util::RunBlockingPoolTask(); 2513 google_apis::test_util::RunBlockingPoolTask();
2510 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_); 2514 EXPECT_EQ(GG_LONGLONG(6789012345), callback_helper_->quota_bytes_used_);
2511 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_); 2515 EXPECT_EQ(GG_LONGLONG(9876543210), callback_helper_->quota_bytes_total_);
2512 } 2516 }
2513 2517
2514 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) { 2518 TEST_F(DriveFileSystemTest, RequestDirectoryRefresh) {
2515 LoadRootFeedDocument("gdata/root_feed.json"); 2519 LoadRootFeedDocument("gdata/root_feed.json");
2516 2520
2517 // We'll fetch documents in the root directory with its resource ID. 2521 // We'll fetch documents in the root directory with its resource ID.
2518 EXPECT_CALL(*mock_drive_service_, 2522 EXPECT_CALL(*mock_drive_service_,
2519 GetDocuments(Eq(GURL()), _, _, kDriveRootDirectoryResourceId, _)) 2523 GetDocuments(Eq(GURL()), _, _, kWAPIRootDirectoryResourceId, _))
2520 .Times(1); 2524 .Times(1);
2521 // We'll notify the directory change to the observer. 2525 // We'll notify the directory change to the observer.
2522 EXPECT_CALL(*mock_directory_observer_, 2526 EXPECT_CALL(*mock_directory_observer_,
2523 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1); 2527 OnDirectoryChanged(Eq(FilePath(kDriveRootDirectory)))).Times(1);
2524 2528
2525 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory)); 2529 file_system_->RequestDirectoryRefresh(FilePath(kDriveRootDirectory));
2526 google_apis::test_util::RunBlockingPoolTask(); 2530 google_apis::test_util::RunBlockingPoolTask();
2527 } 2531 }
2528 2532
2529 TEST_F(DriveFileSystemTest, OpenAndCloseFile) { 2533 TEST_F(DriveFileSystemTest, OpenAndCloseFile) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 2615
2612 // Try to close the same file twice. 2616 // Try to close the same file twice.
2613 file_system_->CloseFile(kFileInRoot, close_file_callback); 2617 file_system_->CloseFile(kFileInRoot, close_file_callback);
2614 message_loop_.Run(); 2618 message_loop_.Run();
2615 2619
2616 // It must fail. 2620 // It must fail.
2617 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2621 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2618 } 2622 }
2619 2623
2620 } // namespace drive 2624 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698