OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/download_handler.h" | 5 #include "chrome/browser/chromeos/drive/download_handler.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/chromeos/drive/dummy_file_system.h" |
9 #include "chrome/browser/chromeos/drive/file_system_util.h" | 10 #include "chrome/browser/chromeos/drive/file_system_util.h" |
10 #include "chrome/browser/chromeos/drive/file_write_helper.h" | 11 #include "chrome/browser/chromeos/drive/file_write_helper.h" |
11 #include "chrome/browser/chromeos/drive/mock_file_system.h" | |
12 #include "chrome/browser/google_apis/test_util.h" | 12 #include "chrome/browser/google_apis/test_util.h" |
13 #include "content/public/test/mock_download_item.h" | 13 #include "content/public/test/mock_download_item.h" |
14 #include "content/public/test/mock_download_manager.h" | 14 #include "content/public/test/mock_download_manager.h" |
15 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 using ::testing::Return; | |
20 using ::testing::SaveArg; | |
21 using ::testing::_; | |
22 | |
23 namespace drive { | 19 namespace drive { |
24 | 20 |
25 namespace { | 21 namespace { |
26 | 22 |
27 // Copies |file_path| to |out_file_path|, is used as a | 23 // Flags to control the state of the test file system. |
28 // SubstituteDriveDownloadPathCallback. | 24 enum DownloadPathState { |
29 void CopySubstituteDriveDownloadPathResult(base::FilePath* out_file_path, | 25 // Simulates the state that requested path just simply exists. |
30 const base::FilePath& file_path) { | 26 PATH_EXISTS, |
31 *out_file_path = file_path; | 27 // Simulates the state that requested path fails to be accessed. |
32 } | 28 PATH_INVALID, |
| 29 // Simulates the state that the requested path does not exist. |
| 30 PATH_NOT_EXIST, |
| 31 // Simulates the state that the path does not exist nor be able to be created. |
| 32 PATH_NOT_EXIST_AND_CREATE_FAIL, |
| 33 }; |
33 | 34 |
34 // Copies |value| to |out|, is used as a content::CheckForFileExistenceCallback. | 35 // Test file system for verifying the behavior of DownloadHandler, by simulating |
35 void CopyCheckForFileExistenceResult(bool* out, bool value) { | 36 // various responses from FileSystem. |
36 *out = value; | 37 class DownloadHandlerTestFileSystem : public DummyFileSystem { |
37 } | 38 public: |
| 39 DownloadHandlerTestFileSystem() : state_(PATH_INVALID) {} |
| 40 |
| 41 void set_download_path_state(DownloadPathState state) { state_ = state; } |
| 42 |
| 43 // FileSystemInterface overrides. |
| 44 virtual void GetResourceEntryByPath( |
| 45 const base::FilePath& file_path, |
| 46 const GetResourceEntryCallback& callback) OVERRIDE { |
| 47 if (state_ == PATH_EXISTS) { |
| 48 callback.Run(FILE_ERROR_OK, make_scoped_ptr(new ResourceEntry)); |
| 49 return; |
| 50 } |
| 51 callback.Run( |
| 52 state_ == PATH_INVALID ? FILE_ERROR_FAILED : FILE_ERROR_NOT_FOUND, |
| 53 scoped_ptr<ResourceEntry>()); |
| 54 } |
| 55 |
| 56 virtual void CreateDirectory( |
| 57 const base::FilePath& directory_path, |
| 58 bool is_exclusive, |
| 59 bool is_recursive, |
| 60 const FileOperationCallback& callback) OVERRIDE { |
| 61 callback.Run(state_ == PATH_NOT_EXIST ? FILE_ERROR_OK : FILE_ERROR_FAILED); |
| 62 } |
| 63 |
| 64 private: |
| 65 DownloadPathState state_; |
| 66 }; |
38 | 67 |
39 } // namespace | 68 } // namespace |
40 | 69 |
41 class DownloadHandlerTest : public testing::Test { | 70 class DownloadHandlerTest : public testing::Test { |
42 public: | 71 public: |
43 DownloadHandlerTest() | 72 DownloadHandlerTest() |
44 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 73 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
45 download_manager_(new content::MockDownloadManager) {} | 74 download_manager_(new content::MockDownloadManager) {} |
46 | 75 |
47 virtual void SetUp() OVERRIDE { | 76 virtual void SetUp() OVERRIDE { |
48 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 77 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
49 | 78 |
50 // Set expectations for download item. | 79 // Set expectations for download item. |
51 EXPECT_CALL(download_item_, GetState()) | 80 EXPECT_CALL(download_item_, GetState()) |
52 .WillRepeatedly(Return(content::DownloadItem::IN_PROGRESS)); | 81 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS)); |
53 | 82 |
54 // Set expectations for file system to save argument callbacks. | 83 file_write_helper_.reset(new FileWriteHelper(&test_file_system_)); |
55 EXPECT_CALL(file_system_, GetResourceEntryByPath(_, _)) | |
56 .WillRepeatedly(SaveArg<1>(&get_entry_info_callback_)); | |
57 EXPECT_CALL(file_system_, CreateDirectory(_, _, _, _)) | |
58 .WillRepeatedly(SaveArg<3>(&create_directory_callback_)); | |
59 | |
60 file_write_helper_.reset(new FileWriteHelper(&file_system_)); | |
61 download_handler_.reset( | 84 download_handler_.reset( |
62 new DownloadHandler(file_write_helper_.get(), &file_system_)); | 85 new DownloadHandler(file_write_helper_.get(), &test_file_system_)); |
63 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); | 86 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); |
64 } | 87 } |
65 | 88 |
66 virtual void TearDown() OVERRIDE { | |
67 } | |
68 | |
69 protected: | 89 protected: |
70 base::ScopedTempDir temp_dir_; | 90 base::ScopedTempDir temp_dir_; |
71 base::MessageLoopForUI message_loop_; | 91 base::MessageLoopForUI message_loop_; |
72 content::TestBrowserThread ui_thread_; | 92 content::TestBrowserThread ui_thread_; |
73 scoped_ptr<content::MockDownloadManager> download_manager_; | 93 scoped_ptr<content::MockDownloadManager> download_manager_; |
74 MockFileSystem file_system_; | 94 DownloadHandlerTestFileSystem test_file_system_; |
75 scoped_ptr<FileWriteHelper> file_write_helper_; | 95 scoped_ptr<FileWriteHelper> file_write_helper_; |
76 scoped_ptr<DownloadHandler> download_handler_; | 96 scoped_ptr<DownloadHandler> download_handler_; |
77 content::MockDownloadItem download_item_; | 97 content::MockDownloadItem download_item_; |
78 | |
79 // Argument callbacks passed to the file system. | |
80 GetResourceEntryCallback get_entry_info_callback_; | |
81 FileOperationCallback create_directory_callback_; | |
82 }; | 98 }; |
83 | 99 |
84 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathNonDrivePath) { | 100 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathNonDrivePath) { |
85 const base::FilePath non_drive_path(FILE_PATH_LITERAL("/foo/bar")); | 101 const base::FilePath non_drive_path(FILE_PATH_LITERAL("/foo/bar")); |
86 ASSERT_FALSE(util::IsUnderDriveMountPoint(non_drive_path)); | 102 ASSERT_FALSE(util::IsUnderDriveMountPoint(non_drive_path)); |
87 | 103 |
88 // Call SubstituteDriveDownloadPath() | 104 // Call SubstituteDriveDownloadPath() |
89 base::FilePath substituted_path; | 105 base::FilePath substituted_path; |
90 download_handler_->SubstituteDriveDownloadPath( | 106 download_handler_->SubstituteDriveDownloadPath( |
91 non_drive_path, | 107 non_drive_path, |
92 &download_item_, | 108 &download_item_, |
93 base::Bind(&CopySubstituteDriveDownloadPathResult, &substituted_path)); | 109 google_apis::test_util::CreateCopyResultCallback(&substituted_path)); |
94 google_apis::test_util::RunBlockingPoolTask(); | 110 google_apis::test_util::RunBlockingPoolTask(); |
95 | 111 |
96 // Check the result. | 112 // Check the result. |
97 EXPECT_EQ(non_drive_path, substituted_path); | 113 EXPECT_EQ(non_drive_path, substituted_path); |
98 EXPECT_FALSE(download_handler_->IsDriveDownload(&download_item_)); | 114 EXPECT_FALSE(download_handler_->IsDriveDownload(&download_item_)); |
99 } | 115 } |
100 | 116 |
101 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPath) { | 117 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPath) { |
102 const base::FilePath drive_path = | 118 const base::FilePath drive_path = |
103 util::GetDriveMountPointPath().AppendASCII("test.dat"); | 119 util::GetDriveMountPointPath().AppendASCII("test.dat"); |
104 | 120 |
| 121 // Test the case that the download target directory already exists. |
| 122 test_file_system_.set_download_path_state(PATH_EXISTS); |
| 123 |
105 // Call SubstituteDriveDownloadPath() | 124 // Call SubstituteDriveDownloadPath() |
106 base::FilePath substituted_path; | 125 base::FilePath substituted_path; |
107 download_handler_->SubstituteDriveDownloadPath( | 126 download_handler_->SubstituteDriveDownloadPath( |
108 drive_path, | 127 drive_path, |
109 &download_item_, | 128 &download_item_, |
110 base::Bind(&CopySubstituteDriveDownloadPathResult, &substituted_path)); | 129 google_apis::test_util::CreateCopyResultCallback(&substituted_path)); |
111 google_apis::test_util::RunBlockingPoolTask(); | |
112 | |
113 // Return result of GetResourceEntryByPath(), destination directory found. | |
114 scoped_ptr<ResourceEntry> entry(new ResourceEntry); | |
115 ASSERT_FALSE(get_entry_info_callback_.is_null()); | |
116 get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); | |
117 google_apis::test_util::RunBlockingPoolTask(); | 130 google_apis::test_util::RunBlockingPoolTask(); |
118 | 131 |
119 // Check the result. | 132 // Check the result. |
120 EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path)); | 133 EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path)); |
121 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); | 134 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); |
122 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); | 135 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); |
123 } | 136 } |
124 | 137 |
125 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathGetEntryFailure) { | 138 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathGetEntryFailure) { |
126 const base::FilePath drive_path = | 139 const base::FilePath drive_path = |
127 util::GetDriveMountPointPath().AppendASCII("test.dat"); | 140 util::GetDriveMountPointPath().AppendASCII("test.dat"); |
128 | 141 |
| 142 // Test the case that access to the download target directory failed for some |
| 143 // reason. |
| 144 test_file_system_.set_download_path_state(PATH_INVALID); |
| 145 |
129 // Call SubstituteDriveDownloadPath() | 146 // Call SubstituteDriveDownloadPath() |
130 base::FilePath substituted_path; | 147 base::FilePath substituted_path; |
131 download_handler_->SubstituteDriveDownloadPath( | 148 download_handler_->SubstituteDriveDownloadPath( |
132 drive_path, | 149 drive_path, |
133 &download_item_, | 150 &download_item_, |
134 base::Bind(&CopySubstituteDriveDownloadPathResult, &substituted_path)); | 151 google_apis::test_util::CreateCopyResultCallback(&substituted_path)); |
135 google_apis::test_util::RunBlockingPoolTask(); | |
136 | |
137 // Return result of GetResourceEntryByPath(), failing for some reason. | |
138 ASSERT_FALSE(get_entry_info_callback_.is_null()); | |
139 get_entry_info_callback_.Run(FILE_ERROR_FAILED, | |
140 scoped_ptr<ResourceEntry>()); | |
141 google_apis::test_util::RunBlockingPoolTask(); | 152 google_apis::test_util::RunBlockingPoolTask(); |
142 | 153 |
143 // Check the result. | 154 // Check the result. |
144 EXPECT_TRUE(substituted_path.empty()); | 155 EXPECT_TRUE(substituted_path.empty()); |
145 } | 156 } |
146 | 157 |
147 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathCreateDirectory) { | 158 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathCreateDirectory) { |
148 const base::FilePath drive_path = | 159 const base::FilePath drive_path = |
149 util::GetDriveMountPointPath().AppendASCII("test.dat"); | 160 util::GetDriveMountPointPath().AppendASCII("test.dat"); |
150 | 161 |
| 162 // Test the case that access to the download target directory does not exist, |
| 163 // and thus will be created in DownloadHandler. |
| 164 test_file_system_.set_download_path_state(PATH_NOT_EXIST); |
| 165 |
151 // Call SubstituteDriveDownloadPath() | 166 // Call SubstituteDriveDownloadPath() |
152 base::FilePath substituted_path; | 167 base::FilePath substituted_path; |
153 download_handler_->SubstituteDriveDownloadPath( | 168 download_handler_->SubstituteDriveDownloadPath( |
154 drive_path, | 169 drive_path, |
155 &download_item_, | 170 &download_item_, |
156 base::Bind(&CopySubstituteDriveDownloadPathResult, &substituted_path)); | 171 google_apis::test_util::CreateCopyResultCallback(&substituted_path)); |
157 google_apis::test_util::RunBlockingPoolTask(); | |
158 | |
159 // Return result of GetResourceEntryByPath(), destination directory not found. | |
160 ASSERT_FALSE(get_entry_info_callback_.is_null()); | |
161 get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, | |
162 scoped_ptr<ResourceEntry>()); | |
163 google_apis::test_util::RunBlockingPoolTask(); | |
164 | |
165 // Return result of CreateDirecotry(). | |
166 ASSERT_FALSE(create_directory_callback_.is_null()); | |
167 create_directory_callback_.Run(FILE_ERROR_OK); | |
168 google_apis::test_util::RunBlockingPoolTask(); | 172 google_apis::test_util::RunBlockingPoolTask(); |
169 | 173 |
170 // Check the result. | 174 // Check the result. |
171 EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path)); | 175 EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path)); |
172 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); | 176 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); |
173 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); | 177 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); |
174 } | 178 } |
175 | 179 |
176 TEST_F(DownloadHandlerTest, | 180 TEST_F(DownloadHandlerTest, |
177 SubstituteDriveDownloadPathCreateDirectoryFailure) { | 181 SubstituteDriveDownloadPathCreateDirectoryFailure) { |
178 const base::FilePath drive_path = | 182 const base::FilePath drive_path = |
179 util::GetDriveMountPointPath().AppendASCII("test.dat"); | 183 util::GetDriveMountPointPath().AppendASCII("test.dat"); |
180 | 184 |
| 185 // Test the case that access to the download target directory does not exist, |
| 186 // and creation fails for some reason. |
| 187 test_file_system_.set_download_path_state(PATH_NOT_EXIST_AND_CREATE_FAIL); |
| 188 |
181 // Call SubstituteDriveDownloadPath() | 189 // Call SubstituteDriveDownloadPath() |
182 base::FilePath substituted_path; | 190 base::FilePath substituted_path; |
183 download_handler_->SubstituteDriveDownloadPath( | 191 download_handler_->SubstituteDriveDownloadPath( |
184 drive_path, | 192 drive_path, |
185 &download_item_, | 193 &download_item_, |
186 base::Bind(&CopySubstituteDriveDownloadPathResult, &substituted_path)); | 194 google_apis::test_util::CreateCopyResultCallback(&substituted_path)); |
187 google_apis::test_util::RunBlockingPoolTask(); | |
188 | |
189 // Return result of GetResourceEntryByPath(), destination directory not found. | |
190 ASSERT_FALSE(get_entry_info_callback_.is_null()); | |
191 get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, | |
192 scoped_ptr<ResourceEntry>()); | |
193 google_apis::test_util::RunBlockingPoolTask(); | |
194 | |
195 // Return result of CreateDirecotry(). | |
196 ASSERT_FALSE(create_directory_callback_.is_null()); | |
197 create_directory_callback_.Run(FILE_ERROR_FAILED); | |
198 google_apis::test_util::RunBlockingPoolTask(); | 195 google_apis::test_util::RunBlockingPoolTask(); |
199 | 196 |
200 // Check the result. | 197 // Check the result. |
201 EXPECT_TRUE(substituted_path.empty()); | 198 EXPECT_TRUE(substituted_path.empty()); |
202 } | 199 } |
203 | 200 |
204 // content::SavePackage calls SubstituteDriveDownloadPath before creating | 201 // content::SavePackage calls SubstituteDriveDownloadPath before creating |
205 // DownloadItem. | 202 // DownloadItem. |
206 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathForSavePackage) { | 203 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathForSavePackage) { |
207 const base::FilePath drive_path = | 204 const base::FilePath drive_path = |
208 util::GetDriveMountPointPath().AppendASCII("test.dat"); | 205 util::GetDriveMountPointPath().AppendASCII("test.dat"); |
| 206 test_file_system_.set_download_path_state(PATH_EXISTS); |
209 | 207 |
210 // Call SubstituteDriveDownloadPath() | 208 // Call SubstituteDriveDownloadPath() |
211 base::FilePath substituted_path; | 209 base::FilePath substituted_path; |
212 download_handler_->SubstituteDriveDownloadPath( | 210 download_handler_->SubstituteDriveDownloadPath( |
213 drive_path, | 211 drive_path, |
214 NULL, // DownloadItem is not available at this moment. | 212 NULL, // DownloadItem is not available at this moment. |
215 base::Bind(&CopySubstituteDriveDownloadPathResult, &substituted_path)); | 213 google_apis::test_util::CreateCopyResultCallback(&substituted_path)); |
216 google_apis::test_util::RunBlockingPoolTask(); | |
217 | |
218 // Return result of GetResourceEntryByPath(), destination directory found. | |
219 scoped_ptr<ResourceEntry> entry(new ResourceEntry); | |
220 ASSERT_FALSE(get_entry_info_callback_.is_null()); | |
221 get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); | |
222 google_apis::test_util::RunBlockingPoolTask(); | 214 google_apis::test_util::RunBlockingPoolTask(); |
223 | 215 |
224 // Check the result of SubstituteDriveDownloadPath(). | 216 // Check the result of SubstituteDriveDownloadPath(). |
225 EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path)); | 217 EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path)); |
226 | 218 |
227 // |download_item_| is not a drive download yet. | 219 // |download_item_| is not a drive download yet. |
228 EXPECT_FALSE(download_handler_->IsDriveDownload(&download_item_)); | 220 EXPECT_FALSE(download_handler_->IsDriveDownload(&download_item_)); |
229 | 221 |
230 // Call SetDownloadParams(). | 222 // Call SetDownloadParams(). |
231 download_handler_->SetDownloadParams(drive_path, &download_item_); | 223 download_handler_->SetDownloadParams(drive_path, &download_item_); |
232 | 224 |
233 // |download_item_| is a drive download now. | 225 // |download_item_| is a drive download now. |
234 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); | 226 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); |
235 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); | 227 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); |
236 } | 228 } |
237 | 229 |
238 TEST_F(DownloadHandlerTest, CheckForFileExistence) { | 230 TEST_F(DownloadHandlerTest, CheckForFileExistence) { |
239 const base::FilePath drive_path = | 231 const base::FilePath drive_path = |
240 util::GetDriveMountPointPath().AppendASCII("test.dat"); | 232 util::GetDriveMountPointPath().AppendASCII("test.dat"); |
241 | 233 |
242 // Make |download_item_| a drive download. | 234 // Make |download_item_| a drive download. |
243 download_handler_->SetDownloadParams(drive_path, &download_item_); | 235 download_handler_->SetDownloadParams(drive_path, &download_item_); |
244 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); | 236 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); |
245 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); | 237 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); |
246 | 238 |
| 239 // Test for the case when the path exists. |
| 240 test_file_system_.set_download_path_state(PATH_EXISTS); |
| 241 |
247 // Call CheckForFileExistence. | 242 // Call CheckForFileExistence. |
248 bool file_exists = false; | 243 bool file_exists = false; |
249 download_handler_->CheckForFileExistence( | 244 download_handler_->CheckForFileExistence( |
250 &download_item_, | 245 &download_item_, |
251 base::Bind(&CopyCheckForFileExistenceResult, &file_exists)); | 246 google_apis::test_util::CreateCopyResultCallback(&file_exists)); |
252 google_apis::test_util::RunBlockingPoolTask(); | |
253 | |
254 // Return result of GetResourceEntryByPath(), file exists. | |
255 { | |
256 scoped_ptr<ResourceEntry> entry(new ResourceEntry); | |
257 ASSERT_FALSE(get_entry_info_callback_.is_null()); | |
258 get_entry_info_callback_.Run(FILE_ERROR_OK, entry.Pass()); | |
259 } | |
260 google_apis::test_util::RunBlockingPoolTask(); | 247 google_apis::test_util::RunBlockingPoolTask(); |
261 | 248 |
262 // Check the result. | 249 // Check the result. |
263 EXPECT_TRUE(file_exists); | 250 EXPECT_TRUE(file_exists); |
264 | 251 |
265 // Reset callback to call CheckForFileExistence again. | 252 // Test for the case when the path does not exist. |
266 get_entry_info_callback_.Reset(); | 253 test_file_system_.set_download_path_state(PATH_NOT_EXIST); |
267 | 254 |
268 // Call CheckForFileExistence again. | 255 // Call CheckForFileExistence again. |
269 download_handler_->CheckForFileExistence( | 256 download_handler_->CheckForFileExistence( |
270 &download_item_, | 257 &download_item_, |
271 base::Bind(&CopyCheckForFileExistenceResult, &file_exists)); | 258 google_apis::test_util::CreateCopyResultCallback(&file_exists)); |
272 google_apis::test_util::RunBlockingPoolTask(); | |
273 | |
274 // Return result of GetResourceEntryByPath(), file does not exist. | |
275 ASSERT_FALSE(get_entry_info_callback_.is_null()); | |
276 get_entry_info_callback_.Run(FILE_ERROR_NOT_FOUND, | |
277 scoped_ptr<ResourceEntry>()); | |
278 google_apis::test_util::RunBlockingPoolTask(); | 259 google_apis::test_util::RunBlockingPoolTask(); |
279 | 260 |
280 // Check the result. | 261 // Check the result. |
281 EXPECT_FALSE(file_exists); | 262 EXPECT_FALSE(file_exists); |
282 } | 263 } |
283 | 264 |
284 } // namespace drive | 265 } // namespace drive |
OLD | NEW |