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

Side by Side Diff: remoting/protocol/channel_multiplexer_unittest.cc

Issue 550383002: Cleanup ChannelFactory interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « remoting/protocol/channel_multiplexer.cc ('k') | remoting/protocol/fake_session.h » ('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 "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
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
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
OLDNEW
« no previous file with comments | « remoting/protocol/channel_multiplexer.cc ('k') | remoting/protocol/fake_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698