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

Side by Side Diff: net/base/elements_upload_data_stream_unittest.cc

Issue 2053133002: Remove MessageLoop::current()->RunUntilIdle() in net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | net/cert/nss_cert_database_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/base/elements_upload_data_stream.h" 5 #include "net/base/elements_upload_data_stream.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/files/scoped_temp_dir.h" 17 #include "base/files/scoped_temp_dir.h"
18 #include "base/location.h" 18 #include "base/location.h"
19 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
20 #include "base/message_loop/message_loop.h"
21 #include "base/run_loop.h" 20 #include "base/run_loop.h"
22 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
23 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
24 #include "base/time/time.h" 23 #include "base/time/time.h"
25 #include "net/base/io_buffer.h" 24 #include "net/base/io_buffer.h"
26 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
27 #include "net/base/test_completion_callback.h" 26 #include "net/base/test_completion_callback.h"
28 #include "net/base/upload_bytes_element_reader.h" 27 #include "net/base/upload_bytes_element_reader.h"
29 #include "net/base/upload_data_stream.h" 28 #include "net/base/upload_data_stream.h"
30 #include "net/base/upload_file_element_reader.h" 29 #include "net/base/upload_file_element_reader.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 TestCompletionCallback init_callback; 495 TestCompletionCallback init_callback;
497 EXPECT_EQ(ERR_IO_PENDING, stream->Init(init_callback.callback())); 496 EXPECT_EQ(ERR_IO_PENDING, stream->Init(init_callback.callback()));
498 EXPECT_EQ(OK, init_callback.WaitForResult()); 497 EXPECT_EQ(OK, init_callback.WaitForResult());
499 498
500 scoped_refptr<IOBuffer> buf = new IOBuffer(kTestBufferSize); 499 scoped_refptr<IOBuffer> buf = new IOBuffer(kTestBufferSize);
501 500
502 // Consume the first element. 501 // Consume the first element.
503 TestCompletionCallback read_callback1; 502 TestCompletionCallback read_callback1;
504 EXPECT_EQ(static_cast<int>(kTestDataSize), 503 EXPECT_EQ(static_cast<int>(kTestDataSize),
505 stream->Read(buf.get(), kTestDataSize, read_callback1.callback())); 504 stream->Read(buf.get(), kTestDataSize, read_callback1.callback()));
506 base::MessageLoop::current()->RunUntilIdle(); 505 base::RunLoop().RunUntilIdle();
507 EXPECT_FALSE(read_callback1.have_result()); 506 EXPECT_FALSE(read_callback1.have_result());
508 507
509 // Consume the second element. 508 // Consume the second element.
510 TestCompletionCallback read_callback2; 509 TestCompletionCallback read_callback2;
511 ASSERT_EQ(ERR_IO_PENDING, 510 ASSERT_EQ(ERR_IO_PENDING,
512 stream->Read(buf.get(), kTestDataSize, read_callback2.callback())); 511 stream->Read(buf.get(), kTestDataSize, read_callback2.callback()));
513 EXPECT_EQ(static_cast<int>(kTestDataSize), read_callback2.WaitForResult()); 512 EXPECT_EQ(static_cast<int>(kTestDataSize), read_callback2.WaitForResult());
514 513
515 // Consume the third and the fourth elements. 514 // Consume the third and the fourth elements.
516 TestCompletionCallback read_callback3; 515 TestCompletionCallback read_callback3;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 wrapped_buffer2.get(), buf2.size(), read_callback2.callback())); 797 wrapped_buffer2.get(), buf2.size(), read_callback2.callback()));
799 EXPECT_EQ(static_cast<int>(buf2.size()), read_callback2.WaitForResult()); 798 EXPECT_EQ(static_cast<int>(buf2.size()), read_callback2.WaitForResult());
800 EXPECT_EQ(expected_data, buf2); 799 EXPECT_EQ(expected_data, buf2);
801 EXPECT_TRUE(stream->IsEOF()); 800 EXPECT_TRUE(stream->IsEOF());
802 801
803 // Make sure callbacks are not called for cancelled operations. 802 // Make sure callbacks are not called for cancelled operations.
804 EXPECT_FALSE(read_callback1.have_result()); 803 EXPECT_FALSE(read_callback1.have_result());
805 } 804 }
806 805
807 } // namespace net 806 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/cert/nss_cert_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698