| 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/chromeos/drive/sync_client.h" | 5 #include "chrome/browser/chromeos/drive/sync_client.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | |
| 8 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/prefs/testing_pref_service.h" | 11 #include "base/prefs/testing_pref_service.h" |
| 13 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 14 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 15 #include "chrome/browser/chromeos/drive/change_list_loader.h" | 14 #include "chrome/browser/chromeos/drive/change_list_loader.h" |
| 16 #include "chrome/browser/chromeos/drive/drive.pb.h" | 15 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 17 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" | 16 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("baz"))); | 200 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("baz"))); |
| 202 | 201 |
| 203 // Prepare a pinned-and-fetched file. | 202 // Prepare a pinned-and-fetched file. |
| 204 const std::string md5_fetched = "md5"; | 203 const std::string md5_fetched = "md5"; |
| 205 EXPECT_EQ(FILE_ERROR_OK, | 204 EXPECT_EQ(FILE_ERROR_OK, |
| 206 cache_->Store(GetLocalId("fetched"), md5_fetched, | 205 cache_->Store(GetLocalId("fetched"), md5_fetched, |
| 207 temp_file, FileCache::FILE_OPERATION_COPY)); | 206 temp_file, FileCache::FILE_OPERATION_COPY)); |
| 208 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("fetched"))); | 207 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("fetched"))); |
| 209 | 208 |
| 210 // Prepare a pinned-and-fetched-and-dirty file. | 209 // Prepare a pinned-and-fetched-and-dirty file. |
| 211 const std::string md5_dirty = ""; // Don't care. | |
| 212 EXPECT_EQ(FILE_ERROR_OK, | 210 EXPECT_EQ(FILE_ERROR_OK, |
| 213 cache_->Store(GetLocalId("dirty"), md5_dirty, | 211 cache_->Store(GetLocalId("dirty"), std::string(), |
| 214 temp_file, FileCache::FILE_OPERATION_COPY)); | 212 temp_file, FileCache::FILE_OPERATION_COPY)); |
| 215 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("dirty"))); | 213 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("dirty"))); |
| 216 scoped_ptr<base::ScopedClosureRunner> file_closer; | |
| 217 EXPECT_EQ(FILE_ERROR_OK, | |
| 218 cache_->OpenForWrite(GetLocalId("dirty"), &file_closer)); | |
| 219 | 214 |
| 220 // Prepare a removed file. | 215 // Prepare a removed file. |
| 221 file_system::RemoveOperation remove_operation( | 216 file_system::RemoveOperation remove_operation( |
| 222 base::MessageLoopProxy::current().get(), &observer_, metadata_.get(), | 217 base::MessageLoopProxy::current().get(), &observer_, metadata_.get(), |
| 223 cache_.get()); | 218 cache_.get()); |
| 224 remove_operation.Remove( | 219 remove_operation.Remove( |
| 225 metadata_->GetFilePath(GetLocalId("removed")), | 220 metadata_->GetFilePath(GetLocalId("removed")), |
| 226 false, // is_recursive | 221 false, // is_recursive |
| 227 google_apis::test_util::CreateCopyResultCallback(&error)); | 222 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 228 base::RunLoop().RunUntilIdle(); | 223 base::RunLoop().RunUntilIdle(); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 ASSERT_FALSE(drive_service_->paused_action().is_null()); | 422 ASSERT_FALSE(drive_service_->paused_action().is_null()); |
| 428 drive_service_->paused_action().Run(); | 423 drive_service_->paused_action().Run(); |
| 429 base::RunLoop().RunUntilIdle(); | 424 base::RunLoop().RunUntilIdle(); |
| 430 | 425 |
| 431 // Task should be run twice. | 426 // Task should be run twice. |
| 432 EXPECT_EQ(2, drive_service_->download_file_count()); | 427 EXPECT_EQ(2, drive_service_->download_file_count()); |
| 433 } | 428 } |
| 434 | 429 |
| 435 } // namespace internal | 430 } // namespace internal |
| 436 } // namespace drive | 431 } // namespace drive |
| OLD | NEW |