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/file_cache.h" | 5 #include "chrome/browser/chromeos/drive/file_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 FileCacheTestOnUIThread() : expected_error_(FILE_ERROR_OK), | 48 FileCacheTestOnUIThread() : expected_error_(FILE_ERROR_OK), |
49 expected_cache_state_(0) { | 49 expected_cache_state_(0) { |
50 } | 50 } |
51 | 51 |
52 virtual void SetUp() OVERRIDE { | 52 virtual void SetUp() OVERRIDE { |
53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
54 const base::FilePath metadata_dir = temp_dir_.path().AppendASCII("meta"); | 54 const base::FilePath metadata_dir = temp_dir_.path().AppendASCII("meta"); |
55 const base::FilePath cache_dir = | 55 const base::FilePath cache_dir = |
56 temp_dir_.path().AppendASCII(kCacheFileDirectory); | 56 temp_dir_.path().AppendASCII(kCacheFileDirectory); |
57 | 57 |
58 ASSERT_TRUE(file_util::CreateDirectory(metadata_dir)); | 58 ASSERT_TRUE(base::CreateDirectory(metadata_dir)); |
59 ASSERT_TRUE(file_util::CreateDirectory(cache_dir)); | 59 ASSERT_TRUE(base::CreateDirectory(cache_dir)); |
60 | 60 |
61 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), | 61 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), |
62 &dummy_file_path_)); | 62 &dummy_file_path_)); |
63 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); | 63 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); |
64 | 64 |
65 scoped_refptr<base::SequencedWorkerPool> pool = | 65 scoped_refptr<base::SequencedWorkerPool> pool = |
66 content::BrowserThread::GetBlockingPool(); | 66 content::BrowserThread::GetBlockingPool(); |
67 blocking_task_runner_ = | 67 blocking_task_runner_ = |
68 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); | 68 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); |
69 | 69 |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 } | 713 } |
714 | 714 |
715 // Tests FileCache methods working with the blocking task runner. | 715 // Tests FileCache methods working with the blocking task runner. |
716 class FileCacheTest : public testing::Test { | 716 class FileCacheTest : public testing::Test { |
717 protected: | 717 protected: |
718 virtual void SetUp() OVERRIDE { | 718 virtual void SetUp() OVERRIDE { |
719 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 719 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
720 const base::FilePath metadata_dir = temp_dir_.path().AppendASCII("meta"); | 720 const base::FilePath metadata_dir = temp_dir_.path().AppendASCII("meta"); |
721 cache_files_dir_ = temp_dir_.path().AppendASCII(kCacheFileDirectory); | 721 cache_files_dir_ = temp_dir_.path().AppendASCII(kCacheFileDirectory); |
722 | 722 |
723 ASSERT_TRUE(file_util::CreateDirectory(metadata_dir)); | 723 ASSERT_TRUE(base::CreateDirectory(metadata_dir)); |
724 ASSERT_TRUE(file_util::CreateDirectory(cache_files_dir_)); | 724 ASSERT_TRUE(base::CreateDirectory(cache_files_dir_)); |
725 | 725 |
726 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); | 726 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); |
727 | 727 |
728 metadata_storage_.reset(new ResourceMetadataStorage( | 728 metadata_storage_.reset(new ResourceMetadataStorage( |
729 metadata_dir, | 729 metadata_dir, |
730 base::MessageLoopProxy::current().get())); | 730 base::MessageLoopProxy::current().get())); |
731 ASSERT_TRUE(metadata_storage_->Initialize()); | 731 ASSERT_TRUE(metadata_storage_->Initialize()); |
732 | 732 |
733 cache_.reset(new FileCache( | 733 cache_.reset(new FileCache( |
734 metadata_storage_.get(), | 734 metadata_storage_.get(), |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 // Clear cache. | 970 // Clear cache. |
971 EXPECT_TRUE(cache_->ClearAll()); | 971 EXPECT_TRUE(cache_->ClearAll()); |
972 | 972 |
973 // Verify that the cache is removed. | 973 // Verify that the cache is removed. |
974 EXPECT_FALSE(cache_->GetCacheEntry(id, &cache_entry)); | 974 EXPECT_FALSE(cache_->GetCacheEntry(id, &cache_entry)); |
975 EXPECT_TRUE(base::IsDirectoryEmpty(cache_files_dir_)); | 975 EXPECT_TRUE(base::IsDirectoryEmpty(cache_files_dir_)); |
976 } | 976 } |
977 | 977 |
978 } // namespace internal | 978 } // namespace internal |
979 } // namespace drive | 979 } // namespace drive |
OLD | NEW |