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

Side by Side Diff: content/browser/fileapi/file_system_operation_impl_write_unittest.cc

Issue 2082343002: Remove calls to deprecated MessageLoop methods in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Created 4 years, 5 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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 }; 179 };
180 180
181 TEST_F(FileSystemOperationImplWriteTest, TestWriteSuccess) { 181 TEST_F(FileSystemOperationImplWriteTest, TestWriteSuccess) {
182 ScopedTextBlob blob(url_request_context(), 182 ScopedTextBlob blob(url_request_context(),
183 "blob-id:success", 183 "blob-id:success",
184 "Hello, world!\n"); 184 "Hello, world!\n");
185 file_system_context_->operation_runner()->Write( 185 file_system_context_->operation_runner()->Write(
186 &url_request_context(), URLForPath(virtual_path_), 186 &url_request_context(), URLForPath(virtual_path_),
187 blob.GetBlobDataHandle(), 187 blob.GetBlobDataHandle(),
188 0, RecordWriteCallback()); 188 0, RecordWriteCallback());
189 base::MessageLoop::current()->Run(); 189 base::RunLoop().Run();
190 190
191 EXPECT_EQ(14, bytes_written()); 191 EXPECT_EQ(14, bytes_written());
192 EXPECT_EQ(base::File::FILE_OK, status()); 192 EXPECT_EQ(base::File::FILE_OK, status());
193 EXPECT_TRUE(complete()); 193 EXPECT_TRUE(complete());
194 194
195 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); 195 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
196 } 196 }
197 197
198 TEST_F(FileSystemOperationImplWriteTest, TestWriteZero) { 198 TEST_F(FileSystemOperationImplWriteTest, TestWriteZero) {
199 ScopedTextBlob blob(url_request_context(), "blob_id:zero", ""); 199 ScopedTextBlob blob(url_request_context(), "blob_id:zero", "");
200 file_system_context_->operation_runner()->Write( 200 file_system_context_->operation_runner()->Write(
201 &url_request_context(), URLForPath(virtual_path_), 201 &url_request_context(), URLForPath(virtual_path_),
202 blob.GetBlobDataHandle(), 0, RecordWriteCallback()); 202 blob.GetBlobDataHandle(), 0, RecordWriteCallback());
203 base::MessageLoop::current()->Run(); 203 base::RunLoop().Run();
204 204
205 EXPECT_EQ(0, bytes_written()); 205 EXPECT_EQ(0, bytes_written());
206 EXPECT_EQ(base::File::FILE_OK, status()); 206 EXPECT_EQ(base::File::FILE_OK, status());
207 EXPECT_TRUE(complete()); 207 EXPECT_TRUE(complete());
208 208
209 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); 209 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
210 } 210 }
211 211
212 212
213 TEST_F(FileSystemOperationImplWriteTest, TestWriteInvalidBlobUrl) { 213 TEST_F(FileSystemOperationImplWriteTest, TestWriteInvalidBlobUrl) {
214 std::unique_ptr<storage::BlobDataHandle> null_handle; 214 std::unique_ptr<storage::BlobDataHandle> null_handle;
215 file_system_context_->operation_runner()->Write( 215 file_system_context_->operation_runner()->Write(
216 &url_request_context(), URLForPath(virtual_path_), std::move(null_handle), 216 &url_request_context(), URLForPath(virtual_path_), std::move(null_handle),
217 0, RecordWriteCallback()); 217 0, RecordWriteCallback());
218 base::MessageLoop::current()->Run(); 218 base::RunLoop().Run();
219 219
220 EXPECT_EQ(0, bytes_written()); 220 EXPECT_EQ(0, bytes_written());
221 EXPECT_EQ(base::File::FILE_ERROR_FAILED, status()); 221 EXPECT_EQ(base::File::FILE_ERROR_FAILED, status());
222 EXPECT_TRUE(complete()); 222 EXPECT_TRUE(complete());
223 223
224 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); 224 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count());
225 } 225 }
226 226
227 TEST_F(FileSystemOperationImplWriteTest, TestWriteInvalidFile) { 227 TEST_F(FileSystemOperationImplWriteTest, TestWriteInvalidFile) {
228 ScopedTextBlob blob(url_request_context(), "blob_id:writeinvalidfile", 228 ScopedTextBlob blob(url_request_context(), "blob_id:writeinvalidfile",
229 "It\'ll not be written."); 229 "It\'ll not be written.");
230 file_system_context_->operation_runner()->Write( 230 file_system_context_->operation_runner()->Write(
231 &url_request_context(), 231 &url_request_context(),
232 URLForPath(base::FilePath(FILE_PATH_LITERAL("nonexist"))), 232 URLForPath(base::FilePath(FILE_PATH_LITERAL("nonexist"))),
233 blob.GetBlobDataHandle(), 0, RecordWriteCallback()); 233 blob.GetBlobDataHandle(), 0, RecordWriteCallback());
234 base::MessageLoop::current()->Run(); 234 base::RunLoop().Run();
235 235
236 EXPECT_EQ(0, bytes_written()); 236 EXPECT_EQ(0, bytes_written());
237 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); 237 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status());
238 EXPECT_TRUE(complete()); 238 EXPECT_TRUE(complete());
239 239
240 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); 240 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
241 } 241 }
242 242
243 TEST_F(FileSystemOperationImplWriteTest, TestWriteDir) { 243 TEST_F(FileSystemOperationImplWriteTest, TestWriteDir) {
244 base::FilePath virtual_dir_path(FILE_PATH_LITERAL("d")); 244 base::FilePath virtual_dir_path(FILE_PATH_LITERAL("d"));
245 file_system_context_->operation_runner()->CreateDirectory( 245 file_system_context_->operation_runner()->CreateDirectory(
246 URLForPath(virtual_dir_path), 246 URLForPath(virtual_dir_path),
247 true /* exclusive */, false /* recursive */, 247 true /* exclusive */, false /* recursive */,
248 base::Bind(&AssertStatusEq, base::File::FILE_OK)); 248 base::Bind(&AssertStatusEq, base::File::FILE_OK));
249 249
250 ScopedTextBlob blob(url_request_context(), "blob:writedir", 250 ScopedTextBlob blob(url_request_context(), "blob:writedir",
251 "It\'ll not be written, too."); 251 "It\'ll not be written, too.");
252 file_system_context_->operation_runner()->Write( 252 file_system_context_->operation_runner()->Write(
253 &url_request_context(), URLForPath(virtual_dir_path), 253 &url_request_context(), URLForPath(virtual_dir_path),
254 blob.GetBlobDataHandle(), 0, RecordWriteCallback()); 254 blob.GetBlobDataHandle(), 0, RecordWriteCallback());
255 base::MessageLoop::current()->Run(); 255 base::RunLoop().Run();
256 256
257 EXPECT_EQ(0, bytes_written()); 257 EXPECT_EQ(0, bytes_written());
258 // TODO(kinuko): This error code is platform- or fileutil- dependent 258 // TODO(kinuko): This error code is platform- or fileutil- dependent
259 // right now. Make it return File::FILE_ERROR_NOT_A_FILE in every case. 259 // right now. Make it return File::FILE_ERROR_NOT_A_FILE in every case.
260 EXPECT_TRUE(status() == base::File::FILE_ERROR_NOT_A_FILE || 260 EXPECT_TRUE(status() == base::File::FILE_ERROR_NOT_A_FILE ||
261 status() == base::File::FILE_ERROR_ACCESS_DENIED || 261 status() == base::File::FILE_ERROR_ACCESS_DENIED ||
262 status() == base::File::FILE_ERROR_FAILED); 262 status() == base::File::FILE_ERROR_FAILED);
263 EXPECT_TRUE(complete()); 263 EXPECT_TRUE(complete());
264 264
265 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); 265 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
266 } 266 }
267 267
268 TEST_F(FileSystemOperationImplWriteTest, TestWriteFailureByQuota) { 268 TEST_F(FileSystemOperationImplWriteTest, TestWriteFailureByQuota) {
269 ScopedTextBlob blob(url_request_context(), "blob:success", 269 ScopedTextBlob blob(url_request_context(), "blob:success",
270 "Hello, world!\n"); 270 "Hello, world!\n");
271 quota_manager_->SetQuota( 271 quota_manager_->SetQuota(
272 kOrigin, FileSystemTypeToQuotaStorageType(kFileSystemType), 10); 272 kOrigin, FileSystemTypeToQuotaStorageType(kFileSystemType), 10);
273 file_system_context_->operation_runner()->Write( 273 file_system_context_->operation_runner()->Write(
274 &url_request_context(), URLForPath(virtual_path_), 274 &url_request_context(), URLForPath(virtual_path_),
275 blob.GetBlobDataHandle(), 0, RecordWriteCallback()); 275 blob.GetBlobDataHandle(), 0, RecordWriteCallback());
276 base::MessageLoop::current()->Run(); 276 base::RunLoop().Run();
277 277
278 EXPECT_EQ(10, bytes_written()); 278 EXPECT_EQ(10, bytes_written());
279 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, status()); 279 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, status());
280 EXPECT_TRUE(complete()); 280 EXPECT_TRUE(complete());
281 281
282 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); 282 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
283 } 283 }
284 284
285 TEST_F(FileSystemOperationImplWriteTest, TestImmediateCancelSuccessfulWrite) { 285 TEST_F(FileSystemOperationImplWriteTest, TestImmediateCancelSuccessfulWrite) {
286 ScopedTextBlob blob(url_request_context(), "blob:success", 286 ScopedTextBlob blob(url_request_context(), "blob:success",
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 EXPECT_EQ(base::File::FILE_ERROR_ABORT, status()); 325 EXPECT_EQ(base::File::FILE_ERROR_ABORT, status());
326 EXPECT_EQ(base::File::FILE_OK, cancel_status()); 326 EXPECT_EQ(base::File::FILE_OK, cancel_status());
327 EXPECT_TRUE(complete()); 327 EXPECT_TRUE(complete());
328 328
329 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); 329 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count());
330 } 330 }
331 331
332 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases. 332 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases.
333 333
334 } // namespace content 334 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698