| OLD | NEW |
| 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 "remoting/protocol/channel_multiplexer.h" | 5 #include "remoting/protocol/channel_multiplexer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 host_socket->PairWith(client_socket); | 87 host_socket->PairWith(client_socket); |
| 88 | 88 |
| 89 // Make writes asynchronous in one direction. | 89 // Make writes asynchronous in one direction. |
| 90 host_socket->set_async_write(true); | 90 host_socket->set_async_write(true); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void CreateChannel(const std::string& name, | 93 void CreateChannel(const std::string& name, |
| 94 scoped_ptr<net::StreamSocket>* host_socket, | 94 scoped_ptr<net::StreamSocket>* host_socket, |
| 95 scoped_ptr<net::StreamSocket>* client_socket) { | 95 scoped_ptr<net::StreamSocket>* client_socket) { |
| 96 int counter = 2; | 96 int counter = 2; |
| 97 host_mux_->CreateStreamChannel(name, base::Bind( | 97 host_mux_->CreateChannel(name, base::Bind( |
| 98 &ChannelMultiplexerTest::OnChannelConnected, base::Unretained(this), | 98 &ChannelMultiplexerTest::OnChannelConnected, base::Unretained(this), |
| 99 host_socket, &counter)); | 99 host_socket, &counter)); |
| 100 client_mux_->CreateStreamChannel(name, base::Bind( | 100 client_mux_->CreateChannel(name, base::Bind( |
| 101 &ChannelMultiplexerTest::OnChannelConnected, base::Unretained(this), | 101 &ChannelMultiplexerTest::OnChannelConnected, base::Unretained(this), |
| 102 client_socket, &counter)); | 102 client_socket, &counter)); |
| 103 | 103 |
| 104 message_loop_.Run(); | 104 message_loop_.Run(); |
| 105 | 105 |
| 106 EXPECT_TRUE(host_socket->get()); | 106 EXPECT_TRUE(host_socket->get()); |
| 107 EXPECT_TRUE(client_socket->get()); | 107 EXPECT_TRUE(client_socket->get()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void OnChannelConnected( | 110 void OnChannelConnected( |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 EXPECT_FALSE(host_mux_.get()); | 348 EXPECT_FALSE(host_mux_.get()); |
| 349 } | 349 } |
| 350 | 350 |
| 351 TEST_F(ChannelMultiplexerTest, SessionFail) { | 351 TEST_F(ChannelMultiplexerTest, SessionFail) { |
| 352 host_session_.set_async_creation(true); | 352 host_session_.set_async_creation(true); |
| 353 host_session_.set_error(AUTHENTICATION_FAILED); | 353 host_session_.set_error(AUTHENTICATION_FAILED); |
| 354 | 354 |
| 355 MockConnectCallback cb1; | 355 MockConnectCallback cb1; |
| 356 MockConnectCallback cb2; | 356 MockConnectCallback cb2; |
| 357 | 357 |
| 358 host_mux_->CreateStreamChannel(kTestChannelName, base::Bind( | 358 host_mux_->CreateChannel(kTestChannelName, base::Bind( |
| 359 &MockConnectCallback::OnConnected, base::Unretained(&cb1))); | 359 &MockConnectCallback::OnConnected, base::Unretained(&cb1))); |
| 360 host_mux_->CreateStreamChannel(kTestChannelName2, base::Bind( | 360 host_mux_->CreateChannel(kTestChannelName2, base::Bind( |
| 361 &MockConnectCallback::OnConnected, base::Unretained(&cb2))); | 361 &MockConnectCallback::OnConnected, base::Unretained(&cb2))); |
| 362 | 362 |
| 363 EXPECT_CALL(cb1, OnConnectedPtr(NULL)) | 363 EXPECT_CALL(cb1, OnConnectedPtr(NULL)) |
| 364 .Times(AtMost(1)) | 364 .Times(AtMost(1)) |
| 365 .WillOnce(InvokeWithoutArgs( | 365 .WillOnce(InvokeWithoutArgs( |
| 366 this, &ChannelMultiplexerTest::DeleteAfterSessionFail)); | 366 this, &ChannelMultiplexerTest::DeleteAfterSessionFail)); |
| 367 EXPECT_CALL(cb2, OnConnectedPtr(_)) | 367 EXPECT_CALL(cb2, OnConnectedPtr(_)) |
| 368 .Times(0); | 368 .Times(0); |
| 369 | 369 |
| 370 base::RunLoop().RunUntilIdle(); | 370 base::RunLoop().RunUntilIdle(); |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace protocol | 373 } // namespace protocol |
| 374 } // namespace remoting | 374 } // namespace remoting |
| OLD | NEW |