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

Side by Side Diff: storage/browser/test/async_file_test_helper.cc

Issue 2815743002: Move a couple of blob tests next to the files they cover. (Closed)
Patch Set: Fix gn check, take 2. Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "storage/browser/test/async_file_test_helper.h"
5 #include "base/bind.h" 6 #include "base/bind.h"
6 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
8 #include "base/run_loop.h" 9 #include "base/run_loop.h"
9 #include "content/public/test/async_file_test_helper.h"
10 #include "storage/browser/fileapi/file_system_backend.h" 10 #include "storage/browser/fileapi/file_system_backend.h"
11 #include "storage/browser/fileapi/file_system_context.h" 11 #include "storage/browser/fileapi/file_system_context.h"
12 #include "storage/browser/fileapi/file_system_operation_runner.h" 12 #include "storage/browser/fileapi/file_system_operation_runner.h"
13 #include "storage/browser/fileapi/file_system_url.h" 13 #include "storage/browser/fileapi/file_system_url.h"
14 #include "storage/browser/quota/quota_manager.h" 14 #include "storage/browser/quota/quota_manager.h"
15 #include "storage/common/fileapi/file_system_util.h" 15 #include "storage/common/fileapi/file_system_util.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 typedef storage::FileSystemOperation::FileEntryList FileEntryList; 20 typedef storage::FileSystemOperation::FileEntryList FileEntryList;
21 21
22 namespace { 22 namespace {
23 23
24 void AssignAndQuit(base::RunLoop* run_loop, 24 void AssignAndQuit(base::RunLoop* run_loop,
25 base::File::Error* result_out, 25 base::File::Error* result_out,
26 base::File::Error result) { 26 base::File::Error result) {
27 *result_out = result; 27 *result_out = result;
28 run_loop->Quit(); 28 run_loop->Quit();
29 } 29 }
30 30
31 base::Callback<void(base::File::Error)> 31 base::Callback<void(base::File::Error)> AssignAndQuitCallback(
32 AssignAndQuitCallback(base::RunLoop* run_loop, 32 base::RunLoop* run_loop,
33 base::File::Error* result) { 33 base::File::Error* result) {
34 return base::Bind(&AssignAndQuit, run_loop, base::Unretained(result)); 34 return base::Bind(&AssignAndQuit, run_loop, base::Unretained(result));
35 } 35 }
36 36
37 void GetMetadataCallback(base::RunLoop* run_loop, 37 void GetMetadataCallback(base::RunLoop* run_loop,
38 base::File::Error* result_out, 38 base::File::Error* result_out,
39 base::File::Info* file_info_out, 39 base::File::Info* file_info_out,
40 base::File::Error result, 40 base::File::Error result,
41 const base::File::Info& file_info) { 41 const base::File::Info& file_info) {
42 *result_out = result; 42 *result_out = result;
43 if (file_info_out) 43 if (file_info_out)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 run_loop.Run(); 111 run_loop.Run();
112 return result; 112 return result;
113 } 113 }
114 114
115 base::File::Error AsyncFileTestHelper::Move( 115 base::File::Error AsyncFileTestHelper::Move(
116 storage::FileSystemContext* context, 116 storage::FileSystemContext* context,
117 const storage::FileSystemURL& src, 117 const storage::FileSystemURL& src,
118 const storage::FileSystemURL& dest) { 118 const storage::FileSystemURL& dest) {
119 base::File::Error result = base::File::FILE_ERROR_FAILED; 119 base::File::Error result = base::File::FILE_ERROR_FAILED;
120 base::RunLoop run_loop; 120 base::RunLoop run_loop;
121 context->operation_runner()->Move(src, 121 context->operation_runner()->Move(src, dest,
122 dest,
123 storage::FileSystemOperation::OPTION_NONE, 122 storage::FileSystemOperation::OPTION_NONE,
124 AssignAndQuitCallback(&run_loop, &result)); 123 AssignAndQuitCallback(&run_loop, &result));
125 run_loop.Run(); 124 run_loop.Run();
126 return result; 125 return result;
127 } 126 }
128 127
129 base::File::Error AsyncFileTestHelper::Remove( 128 base::File::Error AsyncFileTestHelper::Remove(
130 storage::FileSystemContext* context, 129 storage::FileSystemContext* context,
131 const storage::FileSystemURL& url, 130 const storage::FileSystemURL& url,
132 bool recursive) { 131 bool recursive) {
(...skipping 18 matching lines...) Expand all
151 run_loop.Run(); 150 run_loop.Run();
152 return result; 151 return result;
153 } 152 }
154 153
155 base::File::Error AsyncFileTestHelper::CreateDirectory( 154 base::File::Error AsyncFileTestHelper::CreateDirectory(
156 storage::FileSystemContext* context, 155 storage::FileSystemContext* context,
157 const storage::FileSystemURL& url) { 156 const storage::FileSystemURL& url) {
158 base::File::Error result = base::File::FILE_ERROR_FAILED; 157 base::File::Error result = base::File::FILE_ERROR_FAILED;
159 base::RunLoop run_loop; 158 base::RunLoop run_loop;
160 context->operation_runner()->CreateDirectory( 159 context->operation_runner()->CreateDirectory(
161 url, 160 url, false /* exclusive */, false /* recursive */,
162 false /* exclusive */,
163 false /* recursive */,
164 AssignAndQuitCallback(&run_loop, &result)); 161 AssignAndQuitCallback(&run_loop, &result));
165 run_loop.Run(); 162 run_loop.Run();
166 return result; 163 return result;
167 } 164 }
168 165
169 base::File::Error AsyncFileTestHelper::CreateFile( 166 base::File::Error AsyncFileTestHelper::CreateFile(
170 storage::FileSystemContext* context, 167 storage::FileSystemContext* context,
171 const storage::FileSystemURL& url) { 168 const storage::FileSystemURL& url) {
172 base::File::Error result = base::File::FILE_ERROR_FAILED; 169 base::File::Error result = base::File::FILE_ERROR_FAILED;
173 base::RunLoop run_loop; 170 base::RunLoop run_loop;
174 context->operation_runner()->CreateFile( 171 context->operation_runner()->CreateFile(
175 url, false /* exclusive */, 172 url, false /* exclusive */, AssignAndQuitCallback(&run_loop, &result));
176 AssignAndQuitCallback(&run_loop, &result));
177 run_loop.Run(); 173 run_loop.Run();
178 return result; 174 return result;
179 } 175 }
180 176
181 base::File::Error AsyncFileTestHelper::CreateFileWithData( 177 base::File::Error AsyncFileTestHelper::CreateFileWithData(
182 storage::FileSystemContext* context, 178 storage::FileSystemContext* context,
183 const storage::FileSystemURL& url, 179 const storage::FileSystemURL& url,
184 const char* buf, 180 const char* buf,
185 int buf_size) { 181 int buf_size) {
186 base::ScopedTempDir dir; 182 base::ScopedTempDir dir;
(...skipping 22 matching lines...) Expand all
209 return result; 205 return result;
210 } 206 }
211 207
212 base::File::Error AsyncFileTestHelper::GetMetadata( 208 base::File::Error AsyncFileTestHelper::GetMetadata(
213 storage::FileSystemContext* context, 209 storage::FileSystemContext* context,
214 const storage::FileSystemURL& url, 210 const storage::FileSystemURL& url,
215 base::File::Info* file_info) { 211 base::File::Info* file_info) {
216 base::File::Error result = base::File::FILE_ERROR_FAILED; 212 base::File::Error result = base::File::FILE_ERROR_FAILED;
217 base::RunLoop run_loop; 213 base::RunLoop run_loop;
218 context->operation_runner()->GetMetadata( 214 context->operation_runner()->GetMetadata(
219 url, storage::FileSystemOperation::GET_METADATA_FIELD_IS_DIRECTORY | 215 url,
220 storage::FileSystemOperation::GET_METADATA_FIELD_SIZE | 216 storage::FileSystemOperation::GET_METADATA_FIELD_IS_DIRECTORY |
221 storage::FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED, 217 storage::FileSystemOperation::GET_METADATA_FIELD_SIZE |
218 storage::FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED,
222 base::Bind(&GetMetadataCallback, &run_loop, &result, file_info)); 219 base::Bind(&GetMetadataCallback, &run_loop, &result, file_info));
223 run_loop.Run(); 220 run_loop.Run();
224 return result; 221 return result;
225 } 222 }
226 223
227 base::File::Error AsyncFileTestHelper::GetPlatformPath( 224 base::File::Error AsyncFileTestHelper::GetPlatformPath(
228 storage::FileSystemContext* context, 225 storage::FileSystemContext* context,
229 const storage::FileSystemURL& url, 226 const storage::FileSystemURL& url,
230 base::FilePath* platform_path) { 227 base::FilePath* platform_path) {
231 base::File::Error result = base::File::FILE_ERROR_FAILED; 228 base::File::Error result = base::File::FILE_ERROR_FAILED;
(...skipping 23 matching lines...) Expand all
255 } 252 }
256 253
257 storage::QuotaStatusCode AsyncFileTestHelper::GetUsageAndQuota( 254 storage::QuotaStatusCode AsyncFileTestHelper::GetUsageAndQuota(
258 storage::QuotaManager* quota_manager, 255 storage::QuotaManager* quota_manager,
259 const GURL& origin, 256 const GURL& origin,
260 storage::FileSystemType type, 257 storage::FileSystemType type,
261 int64_t* usage, 258 int64_t* usage,
262 int64_t* quota) { 259 int64_t* quota) {
263 storage::QuotaStatusCode status = storage::kQuotaStatusUnknown; 260 storage::QuotaStatusCode status = storage::kQuotaStatusUnknown;
264 quota_manager->GetUsageAndQuota( 261 quota_manager->GetUsageAndQuota(
265 origin, 262 origin, FileSystemTypeToQuotaStorageType(type),
266 FileSystemTypeToQuotaStorageType(type),
267 base::Bind(&DidGetUsageAndQuota, &status, usage, quota)); 263 base::Bind(&DidGetUsageAndQuota, &status, usage, quota));
268 base::RunLoop().RunUntilIdle(); 264 base::RunLoop().RunUntilIdle();
269 return status; 265 return status;
270 } 266 }
271 267
272 } // namespace content 268 } // namespace content
OLDNEW
« no previous file with comments | « storage/browser/test/async_file_test_helper.h ('k') | storage/browser/test/mock_special_storage_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698