Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc

Issue 146833015: drive: FileCache::Store marks the entry as dirty if empty MD5 is given (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/callback_helpers.h"
8 #include "base/file_util.h" 7 #include "base/file_util.h"
9 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
10 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" 9 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h"
11 #include "chrome/browser/chromeos/drive/file_cache.h" 10 #include "chrome/browser/chromeos/drive/file_cache.h"
12 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" 11 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h"
13 #include "chrome/browser/chromeos/drive/file_system_util.h" 12 #include "chrome/browser/chromeos/drive/file_system_util.h"
14 #include "chrome/browser/drive/fake_drive_service.h" 13 #include "chrome/browser/drive/fake_drive_service.h"
15 #include "google_apis/drive/test_util.h" 14 #include "google_apis/drive/test_util.h"
16 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/cros_system_api/constants/cryptohome.h" 16 #include "third_party/cros_system_api/constants/cryptohome.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 std::string(dirty_size, 'x')); 419 std::string(dirty_size, 'x'));
421 420
422 // Store the file as a cache, marking it to be dirty. 421 // Store the file as a cache, marking it to be dirty.
423 FileError error = FILE_ERROR_FAILED; 422 FileError error = FILE_ERROR_FAILED;
424 base::PostTaskAndReplyWithResult( 423 base::PostTaskAndReplyWithResult(
425 blocking_task_runner(), 424 blocking_task_runner(),
426 FROM_HERE, 425 FROM_HERE,
427 base::Bind(&internal::FileCache::Store, 426 base::Bind(&internal::FileCache::Store,
428 base::Unretained(cache()), 427 base::Unretained(cache()),
429 GetLocalId(file_in_root), 428 GetLocalId(file_in_root),
430 src_entry.file_specific_info().md5(), 429 std::string(),
431 dirty_file, 430 dirty_file,
432 internal::FileCache::FILE_OPERATION_COPY), 431 internal::FileCache::FILE_OPERATION_COPY),
433 google_apis::test_util::CreateCopyResultCallback(&error)); 432 google_apis::test_util::CreateCopyResultCallback(&error));
434 test_util::RunBlockingPoolTask(); 433 test_util::RunBlockingPoolTask();
435 EXPECT_EQ(FILE_ERROR_OK, error); 434 EXPECT_EQ(FILE_ERROR_OK, error);
436 scoped_ptr<base::ScopedClosureRunner> file_closer;
437 base::PostTaskAndReplyWithResult(
438 blocking_task_runner(),
439 FROM_HERE,
440 base::Bind(&internal::FileCache::OpenForWrite,
441 base::Unretained(cache()),
442 GetLocalId(file_in_root),
443 &file_closer),
444 google_apis::test_util::CreateCopyResultCallback(&error));
445 test_util::RunBlockingPoolTask();
446 EXPECT_EQ(FILE_ERROR_OK, error);
447 435
448 // Record values passed to GetFileContentInitializedCallback(). 436 // Record values passed to GetFileContentInitializedCallback().
449 FileError init_error; 437 FileError init_error;
450 base::FilePath init_path; 438 base::FilePath init_path;
451 scoped_ptr<ResourceEntry> init_entry; 439 scoped_ptr<ResourceEntry> init_entry;
452 base::Closure cancel_callback; 440 base::Closure cancel_callback;
453 441
454 base::FilePath file_path; 442 base::FilePath file_path;
455 scoped_ptr<ResourceEntry> entry; 443 scoped_ptr<ResourceEntry> entry;
456 operation_->EnsureFileDownloadedByPath( 444 operation_->EnsureFileDownloadedByPath(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 495
508 int64 cache_file_size = 0; 496 int64 cache_file_size = 0;
509 EXPECT_TRUE(base::GetFileSize(cache_file_path, &cache_file_size)); 497 EXPECT_TRUE(base::GetFileSize(cache_file_path, &cache_file_size));
510 EXPECT_EQ(static_cast<int64>(0), cache_file_size); 498 EXPECT_EQ(static_cast<int64>(0), cache_file_size);
511 ASSERT_TRUE(entry); 499 ASSERT_TRUE(entry);
512 EXPECT_EQ(cache_file_size, entry->file_info().size()); 500 EXPECT_EQ(cache_file_size, entry->file_info().size());
513 } 501 }
514 502
515 } // namespace file_system 503 } // namespace file_system
516 } // namespace drive 504 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698