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

Side by Side Diff: webkit/fileapi/local_file_system_operation_write_unittest.cc

Issue 11595003: webkit: Update the calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 <vector> 5 #include <vector>
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 GURL blob_url("blob:success"); 306 GURL blob_url("blob:success");
307 ScopedTextBlob blob(url_request_context_, blob_url, "Hello, world!\n"); 307 ScopedTextBlob blob(url_request_context_, blob_url, "Hello, world!\n");
308 308
309 FileSystemOperation* write_operation = operation(); 309 FileSystemOperation* write_operation = operation();
310 write_operation->Write(&url_request_context_, URLForPath(virtual_path_), 310 write_operation->Write(&url_request_context_, URLForPath(virtual_path_),
311 blob_url, 0, RecordWriteCallback()); 311 blob_url, 0, RecordWriteCallback());
312 write_operation->Cancel(RecordCancelCallback()); 312 write_operation->Cancel(RecordCancelCallback());
313 // We use RunAllPendings() instead of Run() here, because we won't dispatch 313 // We use RunAllPendings() instead of Run() here, because we won't dispatch
314 // callbacks after Cancel() is issued (so no chance to Quit) nor do we need 314 // callbacks after Cancel() is issued (so no chance to Quit) nor do we need
315 // to run another write cycle. 315 // to run another write cycle.
316 MessageLoop::current()->RunAllPending(); 316 MessageLoop::current()->RunUntilIdle();
317 317
318 // Issued Cancel() before receiving any response from Write(), 318 // Issued Cancel() before receiving any response from Write(),
319 // so nothing should have happen. 319 // so nothing should have happen.
320 EXPECT_EQ(0, bytes_written()); 320 EXPECT_EQ(0, bytes_written());
321 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status()); 321 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status());
322 EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status()); 322 EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status());
323 EXPECT_TRUE(complete()); 323 EXPECT_TRUE(complete());
324 324
325 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); 325 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count());
326 } 326 }
327 327
328 TEST_F(LocalFileSystemOperationWriteTest, TestImmediateCancelFailingWrite) { 328 TEST_F(LocalFileSystemOperationWriteTest, TestImmediateCancelFailingWrite) {
329 GURL blob_url("blob:writeinvalidfile"); 329 GURL blob_url("blob:writeinvalidfile");
330 ScopedTextBlob blob(url_request_context_, blob_url, "It\'ll not be written."); 330 ScopedTextBlob blob(url_request_context_, blob_url, "It\'ll not be written.");
331 331
332 FileSystemOperation* write_operation = operation(); 332 FileSystemOperation* write_operation = operation();
333 write_operation->Write(&url_request_context_, 333 write_operation->Write(&url_request_context_,
334 URLForPath(FilePath(FILE_PATH_LITERAL("nonexist"))), 334 URLForPath(FilePath(FILE_PATH_LITERAL("nonexist"))),
335 blob_url, 0, RecordWriteCallback()); 335 blob_url, 0, RecordWriteCallback());
336 write_operation->Cancel(RecordCancelCallback()); 336 write_operation->Cancel(RecordCancelCallback());
337 // We use RunAllPendings() instead of Run() here, because we won't dispatch 337 // We use RunAllPendings() instead of Run() here, because we won't dispatch
338 // callbacks after Cancel() is issued (so no chance to Quit) nor do we need 338 // callbacks after Cancel() is issued (so no chance to Quit) nor do we need
339 // to run another write cycle. 339 // to run another write cycle.
340 MessageLoop::current()->RunAllPending(); 340 MessageLoop::current()->RunUntilIdle();
341 341
342 // Issued Cancel() before receiving any response from Write(), 342 // Issued Cancel() before receiving any response from Write(),
343 // so nothing should have happen. 343 // so nothing should have happen.
344 EXPECT_EQ(0, bytes_written()); 344 EXPECT_EQ(0, bytes_written());
345 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status()); 345 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status());
346 EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status()); 346 EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status());
347 EXPECT_TRUE(complete()); 347 EXPECT_TRUE(complete());
348 348
349 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); 349 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count());
350 } 350 }
351 351
352 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases. 352 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases.
353 353
354 } // namespace fileapi 354 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/local_file_system_operation_unittest.cc ('k') | webkit/fileapi/local_file_system_quota_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698