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 "chrome/browser/google_apis/mock_drive_service.h" | 5 #include "chrome/browser/google_apis/mock_drive_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 ON_CALL(*this, RenameResource(_, _, _)) | 34 ON_CALL(*this, RenameResource(_, _, _)) |
35 .WillByDefault(Invoke(this, &MockDriveService::RenameResourceStub)); | 35 .WillByDefault(Invoke(this, &MockDriveService::RenameResourceStub)); |
36 ON_CALL(*this, AddResourceToDirectory(_, _, _)) | 36 ON_CALL(*this, AddResourceToDirectory(_, _, _)) |
37 .WillByDefault( | 37 .WillByDefault( |
38 Invoke(this, &MockDriveService::AddResourceToDirectoryStub)); | 38 Invoke(this, &MockDriveService::AddResourceToDirectoryStub)); |
39 ON_CALL(*this, RemoveResourceFromDirectory(_, _, _)) | 39 ON_CALL(*this, RemoveResourceFromDirectory(_, _, _)) |
40 .WillByDefault( | 40 .WillByDefault( |
41 Invoke(this, &MockDriveService::RemoveResourceFromDirectoryStub)); | 41 Invoke(this, &MockDriveService::RemoveResourceFromDirectoryStub)); |
42 ON_CALL(*this, AddNewDirectory(_, _, _)) | 42 ON_CALL(*this, AddNewDirectory(_, _, _)) |
43 .WillByDefault(Invoke(this, &MockDriveService::CreateDirectoryStub)); | 43 .WillByDefault(Invoke(this, &MockDriveService::CreateDirectoryStub)); |
44 ON_CALL(*this, DownloadFile(_, _, _, _, _)) | 44 ON_CALL(*this, DownloadFile(_, _, _, _, _, _)) |
45 .WillByDefault(Invoke(this, &MockDriveService::DownloadFileStub)); | 45 .WillByDefault(Invoke(this, &MockDriveService::DownloadFileStub)); |
46 | 46 |
47 // Fill in the default values for mock data. | 47 // Fill in the default values for mock data. |
48 account_metadata_data_ = | 48 account_metadata_data_ = |
49 test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"); | 49 test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"); |
50 directory_data_ = | 50 directory_data_ = |
51 test_util::LoadJSONFile("chromeos/gdata/new_folder_entry.json"); | 51 test_util::LoadJSONFile("chromeos/gdata/new_folder_entry.json"); |
52 } | 52 } |
53 | 53 |
54 MockDriveService::~MockDriveService() {} | 54 MockDriveService::~MockDriveService() {} |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 FROM_HERE, | 121 FROM_HERE, |
122 base::Bind(callback, HTTP_SUCCESS, | 122 base::Bind(callback, HTTP_SUCCESS, |
123 base::Passed(&resource_entry))); | 123 base::Passed(&resource_entry))); |
124 } | 124 } |
125 | 125 |
126 void MockDriveService::DownloadFileStub( | 126 void MockDriveService::DownloadFileStub( |
127 const base::FilePath& virtual_path, | 127 const base::FilePath& virtual_path, |
128 const base::FilePath& local_tmp_path, | 128 const base::FilePath& local_tmp_path, |
129 const GURL& download_url, | 129 const GURL& download_url, |
130 const DownloadActionCallback& download_action_callback, | 130 const DownloadActionCallback& download_action_callback, |
131 const GetContentCallback& get_content_callback) { | 131 const GetContentCallback& get_content_callback, |
| 132 const ProgressCallback& progress_callback) { |
132 GDataErrorCode error = HTTP_SUCCESS; | 133 GDataErrorCode error = HTTP_SUCCESS; |
133 if (file_data_.get()) { | 134 if (file_data_.get()) { |
134 int file_data_size = static_cast<int>(file_data_->size()); | 135 int file_data_size = static_cast<int>(file_data_->size()); |
135 ASSERT_EQ(file_data_size, | 136 ASSERT_EQ(file_data_size, |
136 file_util::WriteFile(local_tmp_path, file_data_->data(), | 137 file_util::WriteFile(local_tmp_path, file_data_->data(), |
137 file_data_size)); | 138 file_data_size)); |
138 } | 139 } |
139 base::MessageLoopProxy::current()->PostTask( | 140 base::MessageLoopProxy::current()->PostTask( |
140 FROM_HERE, | 141 FROM_HERE, |
141 base::Bind(download_action_callback, error, local_tmp_path)); | 142 base::Bind(download_action_callback, error, local_tmp_path)); |
142 } | 143 } |
143 | 144 |
144 } // namespace google_apis | 145 } // namespace google_apis |
OLD | NEW |