| 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 <errno.h> | 5 #include <errno.h> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Verifies that returned proto buffer contains entries specified in search | 126 // Verifies that returned proto buffer contains entries specified in search |
| 127 // feed, and that treing file names are formatted like | 127 // feed, and that treing file names are formatted like |
| 128 // "<resource_id>.<file_name>". | 128 // "<resource_id>.<file_name>". |
| 129 void ContentSearchCallback(MessageLoop* message_loop, | 129 void ContentSearchCallback(MessageLoop* message_loop, |
| 130 base::PlatformFileError error, | 130 base::PlatformFileError error, |
| 131 scoped_ptr<GDataDirectoryProto> dir_proto) { | 131 scoped_ptr<GDataDirectoryProto> dir_proto) { |
| 132 ASSERT_EQ(base::PLATFORM_FILE_OK, error); | 132 ASSERT_EQ(base::PLATFORM_FILE_OK, error); |
| 133 ASSERT_TRUE(dir_proto.get()); | 133 ASSERT_TRUE(dir_proto.get()); |
| 134 | 134 |
| 135 // Search feed contains 2 entries. One file (SubDirectory File 1.txt) and one | 135 // Search feed contains 2 entries. One file (SubDirectory File 1.txt) and one |
| 136 // directory (Directory 1). Entries generated from the fedd should have names | 136 // directory (Directory 1). Entries generated from the feed should have names |
| 137 // in format resource_id.actual_file_name. | 137 // in format resource_id.actual_file_name. |
| 138 ASSERT_EQ(1, dir_proto->child_files_size()); | 138 ASSERT_EQ(1, dir_proto->child_files_size()); |
| 139 EXPECT_EQ("file:2_file_resouce_id.SubDirectory File 1.txt", | 139 EXPECT_EQ("file:2_file_resouce_id.SubDirectory File 1.txt", |
| 140 dir_proto->child_files(0).gdata_entry().file_name()); | 140 dir_proto->child_files(0).gdata_entry().file_name()); |
| 141 | 141 |
| 142 ASSERT_EQ(1, dir_proto->child_directories_size()); | 142 ASSERT_EQ(1, dir_proto->child_directories_size()); |
| 143 EXPECT_EQ("folder:1_folder_resource_id.Directory 1", | 143 EXPECT_EQ("folder:1_folder_resource_id.Directory 1", |
| 144 dir_proto->child_directories(0).gdata_entry().file_name()); | 144 dir_proto->child_directories(0).gdata_entry().file_name()); |
| 145 | 145 |
| 146 message_loop->Quit(); | 146 message_loop->Quit(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Action used to set mock expecteations for GetDocuments. | 149 // Action used to set mock expectations for GetDocuments. |
| 150 ACTION_P2(MockGetDocumentEntryCallback, status, value) { | 150 ACTION_P2(MockGetDocumentEntryCallback, status, value) { |
| 151 base::MessageLoopProxy::current()->PostTask(FROM_HERE, | 151 base::MessageLoopProxy::current()->PostTask(FROM_HERE, |
| 152 base::Bind(arg1, status, base::Passed(value))); | 152 base::Bind(arg1, status, base::Passed(value))); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // anonymous namespace | 155 } // anonymous namespace |
| 156 | 156 |
| 157 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface { | 157 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface { |
| 158 public: | 158 public: |
| 159 virtual ~MockFreeDiskSpaceGetter() {} | 159 virtual ~MockFreeDiskSpaceGetter() {} |
| (...skipping 3299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3459 EXPECT_CALL(*mock_doc_service_, RemoveResourceFromDirectory( | 3459 EXPECT_CALL(*mock_doc_service_, RemoveResourceFromDirectory( |
| 3460 Eq(GURL("https://1_folder_content_url/")), | 3460 Eq(GURL("https://1_folder_content_url/")), |
| 3461 Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")), | 3461 Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")), |
| 3462 "file:2_file_resouce_id", _)) | 3462 "file:2_file_resouce_id", _)) |
| 3463 .Times(1); | 3463 .Times(1); |
| 3464 EXPECT_CALL(*mock_doc_service_, AddResourceToDirectory( | 3464 EXPECT_CALL(*mock_doc_service_, AddResourceToDirectory( |
| 3465 Eq(GURL("https://1_folder_content_url/")), | 3465 Eq(GURL("https://1_folder_content_url/")), |
| 3466 Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")), _)) | 3466 Eq(GURL("https://dir1_file_link_self/file:2_file_resouce_id")), _)) |
| 3467 .Times(1); | 3467 .Times(1); |
| 3468 | 3468 |
| 3469 // Statr the test. | 3469 // Start the test. |
| 3470 FilePath source_path_search(FILE_PATH_LITERAL( | 3470 FilePath source_path_search(FILE_PATH_LITERAL( |
| 3471 "drive/.search/foo/folder:1_folder_resource_id.Directory 1/" | 3471 "drive/.search/foo/folder:1_folder_resource_id.Directory 1/" |
| 3472 "SubDirectory File 1.txt")); | 3472 "SubDirectory File 1.txt")); |
| 3473 FilePath source_path_real(FILE_PATH_LITERAL( | 3473 FilePath source_path_real(FILE_PATH_LITERAL( |
| 3474 "drive/Directory 1/SubDirectory File 1.txt")); | 3474 "drive/Directory 1/SubDirectory File 1.txt")); |
| 3475 | 3475 |
| 3476 FilePath destination_path_search(FILE_PATH_LITERAL( | 3476 FilePath destination_path_search(FILE_PATH_LITERAL( |
| 3477 "drive/.search/foo/folder:1_folder_resource_id.Directory 1/" | 3477 "drive/.search/foo/folder:1_folder_resource_id.Directory 1/" |
| 3478 "Sub Directory Folder/SubDirectory File 1.txt.dest")); | 3478 "Sub Directory Folder/SubDirectory File 1.txt.dest")); |
| 3479 FilePath destination_path_real(FILE_PATH_LITERAL( | 3479 FilePath destination_path_real(FILE_PATH_LITERAL( |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3737 .Times(1); | 3737 .Times(1); |
| 3738 // We'll notify the directory change to the observer. | 3738 // We'll notify the directory change to the observer. |
| 3739 EXPECT_CALL(*mock_directory_observer_, | 3739 EXPECT_CALL(*mock_directory_observer_, |
| 3740 OnDirectoryChanged(Eq(FilePath(kGDataRootDirectory)))).Times(1); | 3740 OnDirectoryChanged(Eq(FilePath(kGDataRootDirectory)))).Times(1); |
| 3741 | 3741 |
| 3742 file_system_->RequestDirectoryRefresh(FilePath(kGDataRootDirectory)); | 3742 file_system_->RequestDirectoryRefresh(FilePath(kGDataRootDirectory)); |
| 3743 message_loop_.RunAllPending(); | 3743 message_loop_.RunAllPending(); |
| 3744 } | 3744 } |
| 3745 | 3745 |
| 3746 } // namespace gdata | 3746 } // namespace gdata |
| OLD | NEW |