| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/file_system/download_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/task_runner_util.h" | 8 #include "base/task_runner_util.h" |
| 9 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" | 9 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" |
| 10 #include "chrome/browser/chromeos/drive/file_cache.h" | 10 #include "chrome/browser/chromeos/drive/file_cache.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 google_apis::GetContentCallback(), | 190 google_apis::GetContentCallback(), |
| 191 google_apis::test_util::CreateCopyResultCallback( | 191 google_apis::test_util::CreateCopyResultCallback( |
| 192 &error, &file_path, &entry)); | 192 &error, &file_path, &entry)); |
| 193 test_util::RunBlockingPoolTask(); | 193 test_util::RunBlockingPoolTask(); |
| 194 | 194 |
| 195 EXPECT_EQ(FILE_ERROR_NO_LOCAL_SPACE, error); | 195 EXPECT_EQ(FILE_ERROR_NO_LOCAL_SPACE, error); |
| 196 } | 196 } |
| 197 | 197 |
| 198 TEST_F(DownloadOperationTest, EnsureFileDownloadedByPath_FromCache) { | 198 TEST_F(DownloadOperationTest, EnsureFileDownloadedByPath_FromCache) { |
| 199 base::FilePath temp_file; | 199 base::FilePath temp_file; |
| 200 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir(), &temp_file)); | 200 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir(), &temp_file)); |
| 201 | 201 |
| 202 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 202 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 203 ResourceEntry src_entry; | 203 ResourceEntry src_entry; |
| 204 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry)); | 204 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry)); |
| 205 | 205 |
| 206 // Store something as cached version of this file. | 206 // Store something as cached version of this file. |
| 207 FileError error = FILE_ERROR_OK; | 207 FileError error = FILE_ERROR_OK; |
| 208 base::PostTaskAndReplyWithResult( | 208 base::PostTaskAndReplyWithResult( |
| 209 blocking_task_runner(), | 209 blocking_task_runner(), |
| 210 FROM_HERE, | 210 FROM_HERE, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 EXPECT_TRUE(get_content_callback.data().empty()); | 357 EXPECT_TRUE(get_content_callback.data().empty()); |
| 358 int64 local_file_size = 0; | 358 int64 local_file_size = 0; |
| 359 file_util::GetFileSize(local_path, &local_file_size); | 359 file_util::GetFileSize(local_path, &local_file_size); |
| 360 EXPECT_EQ(entry->file_info().size(), local_file_size); | 360 EXPECT_EQ(entry->file_info().size(), local_file_size); |
| 361 EXPECT_EQ(FILE_ERROR_OK, completion_error); | 361 EXPECT_EQ(FILE_ERROR_OK, completion_error); |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 | 364 |
| 365 TEST_F(DownloadOperationTest, EnsureFileDownloadedByLocalId_FromCache) { | 365 TEST_F(DownloadOperationTest, EnsureFileDownloadedByLocalId_FromCache) { |
| 366 base::FilePath temp_file; | 366 base::FilePath temp_file; |
| 367 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir(), &temp_file)); | 367 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir(), &temp_file)); |
| 368 | 368 |
| 369 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 369 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 370 ResourceEntry src_entry; | 370 ResourceEntry src_entry; |
| 371 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry)); | 371 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry)); |
| 372 | 372 |
| 373 // Store something as cached version of this file. | 373 // Store something as cached version of this file. |
| 374 FileError error = FILE_ERROR_FAILED; | 374 FileError error = FILE_ERROR_FAILED; |
| 375 base::PostTaskAndReplyWithResult( | 375 base::PostTaskAndReplyWithResult( |
| 376 blocking_task_runner(), | 376 blocking_task_runner(), |
| 377 FROM_HERE, | 377 FROM_HERE, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 test_util::RunBlockingPoolTask(); | 460 test_util::RunBlockingPoolTask(); |
| 461 | 461 |
| 462 EXPECT_EQ(FILE_ERROR_OK, error); | 462 EXPECT_EQ(FILE_ERROR_OK, error); |
| 463 // Check that the result of local modification is propagated. | 463 // Check that the result of local modification is propagated. |
| 464 EXPECT_EQ(static_cast<int64>(dirty_size), init_entry->file_info().size()); | 464 EXPECT_EQ(static_cast<int64>(dirty_size), init_entry->file_info().size()); |
| 465 EXPECT_EQ(static_cast<int64>(dirty_size), entry->file_info().size()); | 465 EXPECT_EQ(static_cast<int64>(dirty_size), entry->file_info().size()); |
| 466 } | 466 } |
| 467 | 467 |
| 468 } // namespace file_system | 468 } // namespace file_system |
| 469 } // namespace drive | 469 } // namespace drive |
| OLD | NEW |