| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 ASSERT_TRUE(entry); | 138 ASSERT_TRUE(entry); |
| 139 EXPECT_FALSE(entry->file_specific_info().is_hosted_document()); | 139 EXPECT_FALSE(entry->file_specific_info().is_hosted_document()); |
| 140 | 140 |
| 141 // The transfered file is cached and the change of "offline available" | 141 // The transfered file is cached and the change of "offline available" |
| 142 // attribute is notified. | 142 // attribute is notified. |
| 143 EXPECT_EQ(1U, observer()->get_changed_paths().size()); | 143 EXPECT_EQ(1U, observer()->get_changed_paths().size()); |
| 144 EXPECT_EQ(1U, observer()->get_changed_paths().count(file_in_root.DirName())); | 144 EXPECT_EQ(1U, observer()->get_changed_paths().count(file_in_root.DirName())); |
| 145 | 145 |
| 146 // The cache entry should be removed in order to free up space. | 146 // The cache entry should be removed in order to free up space. |
| 147 FileCacheEntry cache_entry; | 147 FileCacheEntry cache_entry; |
| 148 bool result = true; | |
| 149 base::PostTaskAndReplyWithResult( | 148 base::PostTaskAndReplyWithResult( |
| 150 blocking_task_runner(), | 149 blocking_task_runner(), |
| 151 FROM_HERE, | 150 FROM_HERE, |
| 152 base::Bind(&internal::FileCache::GetCacheEntry, | 151 base::Bind(&internal::FileCache::GetCacheEntry, |
| 153 base::Unretained(cache()), | 152 base::Unretained(cache()), |
| 154 "<id>", | 153 "<id>", |
| 155 &cache_entry), | 154 &cache_entry), |
| 156 google_apis::test_util::CreateCopyResultCallback(&result)); | 155 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 157 test_util::RunBlockingPoolTask(); | 156 test_util::RunBlockingPoolTask(); |
| 158 ASSERT_FALSE(result); | 157 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); |
| 159 } | 158 } |
| 160 | 159 |
| 161 TEST_F(DownloadOperationTest, | 160 TEST_F(DownloadOperationTest, |
| 162 EnsureFileDownloadedByPath_FromServer_EnoughSpaceButBecomeFull) { | 161 EnsureFileDownloadedByPath_FromServer_EnoughSpaceButBecomeFull) { |
| 163 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 162 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 164 ResourceEntry src_entry; | 163 ResourceEntry src_entry; |
| 165 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry)); | 164 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry)); |
| 166 const int64 file_size = src_entry.file_info().size(); | 165 const int64 file_size = src_entry.file_info().size(); |
| 167 | 166 |
| 168 // Pretend we have enough space first (checked before downloading a file), | 167 // Pretend we have enough space first (checked before downloading a file), |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 // Cancel immediately. | 505 // Cancel immediately. |
| 507 ASSERT_FALSE(cancel_closure.is_null()); | 506 ASSERT_FALSE(cancel_closure.is_null()); |
| 508 cancel_closure.Run(); | 507 cancel_closure.Run(); |
| 509 test_util::RunBlockingPoolTask(); | 508 test_util::RunBlockingPoolTask(); |
| 510 | 509 |
| 511 EXPECT_EQ(FILE_ERROR_ABORT, error); | 510 EXPECT_EQ(FILE_ERROR_ABORT, error); |
| 512 } | 511 } |
| 513 | 512 |
| 514 } // namespace file_system | 513 } // namespace file_system |
| 515 } // namespace drive | 514 } // namespace drive |
| OLD | NEW |