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

Side by Side Diff: chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc

Issue 15060002: drive: Rename FileCache methods in a blocking pool centric manner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove virtual Created 7 years, 7 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 (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 <string> 5 #include <string>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 TEST_F(StaleCacheFilesRemoverTest, RemoveStaleCacheFiles) { 114 TEST_F(StaleCacheFilesRemoverTest, RemoveStaleCacheFiles) {
115 base::FilePath dummy_file = 115 base::FilePath dummy_file =
116 google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json"); 116 google_apis::test_util::GetTestFilePath("chromeos/gdata/root_feed.json");
117 std::string resource_id("pdf:1a2b3c"); 117 std::string resource_id("pdf:1a2b3c");
118 std::string md5("abcdef0123456789"); 118 std::string md5("abcdef0123456789");
119 119
120 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace); 120 fake_free_disk_space_getter_->set_fake_free_disk_space(kLotsOfSpace);
121 121
122 // Create a stale cache file. 122 // Create a stale cache file.
123 FileError error = FILE_ERROR_OK; 123 FileError error = FILE_ERROR_OK;
124 cache_->Store(resource_id, md5, dummy_file, 124 cache_->StoreOnUIThread(
125 internal::FileCache::FILE_OPERATION_COPY, 125 resource_id, md5, dummy_file,
126 google_apis::test_util::CreateCopyResultCallback(&error)); 126 internal::FileCache::FILE_OPERATION_COPY,
127 google_apis::test_util::CreateCopyResultCallback(&error));
127 google_apis::test_util::RunBlockingPoolTask(); 128 google_apis::test_util::RunBlockingPoolTask();
128 EXPECT_EQ(FILE_ERROR_OK, error); 129 EXPECT_EQ(FILE_ERROR_OK, error);
129 130
130 // Verify that the cache entry exists. 131 // Verify that the cache entry exists.
131 bool success = false; 132 bool success = false;
132 FileCacheEntry cache_entry; 133 FileCacheEntry cache_entry;
133 cache_->GetCacheEntry(resource_id, md5, 134 cache_->GetCacheEntryOnUIThread(
134 google_apis::test_util::CreateCopyResultCallback( 135 resource_id, md5,
135 &success, &cache_entry)); 136 google_apis::test_util::CreateCopyResultCallback(&success, &cache_entry));
136 google_apis::test_util::RunBlockingPoolTask(); 137 google_apis::test_util::RunBlockingPoolTask();
137 EXPECT_TRUE(success); 138 EXPECT_TRUE(success);
138 139
139 base::FilePath unused; 140 base::FilePath unused;
140 scoped_ptr<ResourceEntry> entry; 141 scoped_ptr<ResourceEntry> entry;
141 file_system_->GetEntryInfoByResourceId( 142 file_system_->GetEntryInfoByResourceId(
142 resource_id, 143 resource_id,
143 google_apis::test_util::CreateCopyResultCallback( 144 google_apis::test_util::CreateCopyResultCallback(
144 &error, &unused, &entry)); 145 &error, &unused, &entry));
145 google_apis::test_util::RunBlockingPoolTask(); 146 google_apis::test_util::RunBlockingPoolTask();
146 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); 147 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error);
147 EXPECT_FALSE(entry.get()); 148 EXPECT_FALSE(entry.get());
148 149
149 // Load a root feed again to kick the StaleCacheFilesRemover. 150 // Load a root feed again to kick the StaleCacheFilesRemover.
150 file_system_->Reload(); 151 file_system_->Reload();
151 152
152 // Wait for StaleCacheFilesRemover to finish cleaning up the stale file. 153 // Wait for StaleCacheFilesRemover to finish cleaning up the stale file.
153 google_apis::test_util::RunBlockingPoolTask(); 154 google_apis::test_util::RunBlockingPoolTask();
154 155
155 // Verify that the cache entry is deleted. 156 // Verify that the cache entry is deleted.
156 cache_->GetCacheEntry(resource_id, md5, 157 cache_->GetCacheEntryOnUIThread(
157 google_apis::test_util::CreateCopyResultCallback( 158 resource_id, md5,
158 &success, &cache_entry)); 159 google_apis::test_util::CreateCopyResultCallback(&success, &cache_entry));
159 google_apis::test_util::RunBlockingPoolTask(); 160 google_apis::test_util::RunBlockingPoolTask();
160 EXPECT_FALSE(success); 161 EXPECT_FALSE(success);
161 } 162 }
162 163
163 } // namespace drive 164 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/stale_cache_files_remover.cc ('k') | chrome/browser/chromeos/drive/sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698