From eda79edcb13a56625b66c891d66fe534253964c7 Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Fri, 24 Jan 2014 15:30:16 +0000 Subject: Migrate remoting/ to base::RunLoop::RunUntilIdle(); base::MessageLoop::RunUntilIdle() API is deprecated and the preferred way is using RunLoop now. BUG=333558 TEST=remoting_unittests R=sergeyu@chromium.org,wez@chromium.org Review URL: https://codereview.chromium.org/144753006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246897 0039d316-1c4b-4281-b951-d872f2087c98 --- .../protocol/buffered_socket_writer_unittest.cc | 5 +++-- remoting/protocol/channel_multiplexer_unittest.cc | 9 ++++---- remoting/protocol/connection_to_client_unittest.cc | 15 +++++++------ remoting/protocol/jingle_session_unittest.cc | 7 +++--- remoting/protocol/message_reader_unittest.cc | 25 +++++++++++----------- 5 files changed, 33 insertions(+), 28 deletions(-) (limited to 'remoting/protocol') diff --git a/remoting/protocol/buffered_socket_writer_unittest.cc b/remoting/protocol/buffered_socket_writer_unittest.cc index baca882..62fb2d9 100644 --- a/remoting/protocol/buffered_socket_writer_unittest.cc +++ b/remoting/protocol/buffered_socket_writer_unittest.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "remoting/protocol/fake_session.h" @@ -162,7 +163,7 @@ TEST_F(BufferedSocketWriterTest, TestWriteErrorSync) { base::Unretained(this))); socket_->set_next_write_error(net::ERR_FAILED); socket_->set_async_write(false); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(net::ERR_FAILED, write_error_); EXPECT_EQ(static_cast(test_buffer_->size()), socket_->written_data().size()); @@ -177,7 +178,7 @@ TEST_F(BufferedSocketWriterTest, TestWriteErrorAsync) { base::Bind(&BufferedSocketWriterTest::Unexpected, base::Unretained(this))); socket_->set_next_write_error(net::ERR_FAILED); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(net::ERR_FAILED, write_error_); EXPECT_EQ(static_cast(test_buffer_->size()), socket_->written_data().size()); diff --git a/remoting/protocol/channel_multiplexer_unittest.cc b/remoting/protocol/channel_multiplexer_unittest.cc index f437cb3..32be47b 100644 --- a/remoting/protocol/channel_multiplexer_unittest.cc +++ b/remoting/protocol/channel_multiplexer_unittest.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "net/base/net_errors.h" #include "net/socket/socket.h" #include "net/socket/stream_socket.h" @@ -267,7 +268,7 @@ TEST_F(ChannelMultiplexerTest, WriteFailSync) { base::Bind(&MockSocketCallback::OnDone, base::Unretained(&cb2)))); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST_F(ChannelMultiplexerTest, WriteFailAsync) { @@ -302,7 +303,7 @@ TEST_F(ChannelMultiplexerTest, WriteFailAsync) { base::Bind(&MockSocketCallback::OnDone, base::Unretained(&cb2)))); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST_F(ChannelMultiplexerTest, DeleteWhenFailed) { @@ -341,7 +342,7 @@ TEST_F(ChannelMultiplexerTest, DeleteWhenFailed) { base::Bind(&MockSocketCallback::OnDone, base::Unretained(&cb2)))); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); // Check that the sockets were destroyed. EXPECT_FALSE(host_mux_.get()); @@ -366,7 +367,7 @@ TEST_F(ChannelMultiplexerTest, SessionFail) { EXPECT_CALL(cb2, OnConnectedPtr(_)) .Times(0); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } } // namespace protocol diff --git a/remoting/protocol/connection_to_client_unittest.cc b/remoting/protocol/connection_to_client_unittest.cc index faffb3c..c6dd90c 100644 --- a/remoting/protocol/connection_to_client_unittest.cc +++ b/remoting/protocol/connection_to_client_unittest.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_proxy.h" +#include "base/run_loop.h" #include "remoting/base/constants.h" #include "remoting/protocol/fake_session.h" #include "remoting/protocol/protocol_mock_objects.h" @@ -38,12 +39,12 @@ class ConnectionToClientTest : public testing::Test { EXPECT_CALL(handler_, OnConnectionChannelsConnected(viewer_.get())); session_->event_handler()->OnSessionStateChange(Session::CONNECTED); session_->event_handler()->OnSessionStateChange(Session::AUTHENTICATED); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } virtual void TearDown() OVERRIDE { viewer_.reset(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } base::MessageLoop message_loop_; @@ -64,7 +65,7 @@ TEST_F(ConnectionToClientTest, SendUpdateStream) { scoped_ptr packet(new VideoPacket()); viewer_->video_stub()->ProcessVideoPacket(packet.Pass(), base::Closure()); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); // Verify that something has been written. // TODO(sergeyu): Verify that the correct data has been written. @@ -75,7 +76,7 @@ TEST_F(ConnectionToClientTest, SendUpdateStream) { // And then close the connection to ConnectionToClient. viewer_->Disconnect(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST_F(ConnectionToClientTest, NoWriteAfterDisconnect) { @@ -88,18 +89,18 @@ TEST_F(ConnectionToClientTest, NoWriteAfterDisconnect) { // The test will crash if data writer tries to write data to the // channel socket. // TODO(sergeyu): Use MockSession to verify that no data is written? - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } TEST_F(ConnectionToClientTest, StateChange) { EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get(), OK)); session_->event_handler()->OnSessionStateChange(Session::CLOSED); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get(), SESSION_REJECTED)); session_->set_error(SESSION_REJECTED); session_->event_handler()->OnSessionStateChange(Session::FAILED); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } } // namespace protocol diff --git a/remoting/protocol/jingle_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc index 62e4d40..dcca077 100644 --- a/remoting/protocol/jingle_session_unittest.cc +++ b/remoting/protocol/jingle_session_unittest.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/test/test_timeouts.h" #include "base/time/time.h" #include "net/socket/socket.h" @@ -121,7 +122,7 @@ class JingleSessionTest : public testing::Test { virtual void TearDown() { CloseSessions(); CloseSessionManager(); - message_loop_->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } void CloseSessions() { @@ -239,7 +240,7 @@ class JingleSessionTest : public testing::Test { CandidateSessionConfig::CreateDefault()); client_session_->SetEventHandler(&client_session_event_handler_); - message_loop_->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } void CreateChannel() { @@ -322,7 +323,7 @@ TEST_F(JingleSessionTest, RejectConnection) { kHostJid, authenticator.Pass(), CandidateSessionConfig::CreateDefault()); client_session_->SetEventHandler(&client_session_event_handler_); - message_loop_->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } // Verify that we can connect two endpoints with single-step authentication. diff --git a/remoting/protocol/message_reader_unittest.cc b/remoting/protocol/message_reader_unittest.cc index 934a5b6..497e7a5 100644 --- a/remoting/protocol/message_reader_unittest.cc +++ b/remoting/protocol/message_reader_unittest.cc @@ -8,6 +8,7 @@ #include "base/bind_helpers.h" #include "base/callback.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/stl_util.h" #include "base/synchronization/waitable_event.h" #include "net/base/net_errors.h" @@ -117,7 +118,7 @@ TEST_F(MessageReaderTest, OneMessage_Delay) { .WillOnce(SaveArg<0>(&done_task)); InitReader(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&callback_); Mock::VerifyAndClearExpectations(&socket_); @@ -142,7 +143,7 @@ TEST_F(MessageReaderTest, OneMessage_Instant) { .WillOnce(CallDoneTask()); InitReader(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(socket_.read_pending()); EXPECT_EQ(1U, messages_.size()); @@ -162,7 +163,7 @@ TEST_F(MessageReaderTest, TwoMessages_Together) { .WillOnce(SaveArg<0>(&done_task2)); InitReader(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&callback_); Mock::VerifyAndClearExpectations(&socket_); @@ -175,12 +176,12 @@ TEST_F(MessageReaderTest, TwoMessages_Together) { EXPECT_FALSE(socket_.read_pending()); done_task1.Run(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_FALSE(socket_.read_pending()); done_task2.Run(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(socket_.read_pending()); } @@ -199,7 +200,7 @@ TEST_F(MessageReaderTest, TwoMessages_Instant) { .WillOnce(SaveArg<0>(&done_task2)); InitReader(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&callback_); Mock::VerifyAndClearExpectations(&socket_); @@ -227,7 +228,7 @@ TEST_F(MessageReaderTest, TwoMessages_Instant2) { .WillOnce(CallDoneTask()); InitReader(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(socket_.read_pending()); } @@ -243,7 +244,7 @@ TEST_F(MessageReaderTest, TwoMessages_Separately) { .WillOnce(SaveArg<0>(&done_task)); InitReader(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); Mock::VerifyAndClearExpectations(&callback_); Mock::VerifyAndClearExpectations(&socket_); @@ -255,7 +256,7 @@ TEST_F(MessageReaderTest, TwoMessages_Separately) { EXPECT_FALSE(socket_.read_pending()); done_task.Run(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(socket_.read_pending()); @@ -264,7 +265,7 @@ TEST_F(MessageReaderTest, TwoMessages_Separately) { .Times(1) .WillOnce(SaveArg<0>(&done_task)); AddMessage(kTestMessage2); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(CompareResult(messages_[1], kTestMessage2)); @@ -300,7 +301,7 @@ TEST_F(MessageReaderTest, ReadFromCallback) { .WillOnce(Invoke(this, &MessageReaderTest::OnSecondMessage)); InitReader(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(socket_.read_pending()); } @@ -319,7 +320,7 @@ TEST_F(MessageReaderTest, DeleteFromCallback) { .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader)); InitReader(); - message_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } } // namespace protocol -- cgit v1.1