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

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

Issue 15782010: Update remoting/ and jingle/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/channel_multiplexer.cc ('k') | remoting/protocol/connection_tester.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 "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.h" 8 #include "base/message_loop.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/socket/socket.h" 10 #include "net/socket/socket.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 scoped_refptr<net::IOBufferWithSize> buf = CreateTestBuffer(100); 249 scoped_refptr<net::IOBufferWithSize> buf = CreateTestBuffer(100);
250 250
251 MockSocketCallback cb1; 251 MockSocketCallback cb1;
252 MockSocketCallback cb2; 252 MockSocketCallback cb2;
253 253
254 EXPECT_CALL(cb1, OnDone(_)) 254 EXPECT_CALL(cb1, OnDone(_))
255 .Times(0); 255 .Times(0);
256 EXPECT_CALL(cb2, OnDone(_)) 256 EXPECT_CALL(cb2, OnDone(_))
257 .Times(0); 257 .Times(0);
258 258
259 EXPECT_EQ(net::ERR_FAILED, host_socket1_->Write(buf, buf->size(), base::Bind( 259 EXPECT_EQ(net::ERR_FAILED,
260 &MockSocketCallback::OnDone, base::Unretained(&cb1)))); 260 host_socket1_->Write(buf.get(),
261 EXPECT_EQ(net::ERR_FAILED, host_socket2_->Write(buf, buf->size(), base::Bind( 261 buf->size(),
262 &MockSocketCallback::OnDone, base::Unretained(&cb2)))); 262 base::Bind(&MockSocketCallback::OnDone,
263 base::Unretained(&cb1))));
264 EXPECT_EQ(net::ERR_FAILED,
265 host_socket2_->Write(buf.get(),
266 buf->size(),
267 base::Bind(&MockSocketCallback::OnDone,
268 base::Unretained(&cb2))));
263 269
264 message_loop_.RunUntilIdle(); 270 message_loop_.RunUntilIdle();
265 } 271 }
266 272
267 TEST_F(ChannelMultiplexerTest, WriteFailAsync) { 273 TEST_F(ChannelMultiplexerTest, WriteFailAsync) {
268 ASSERT_NO_FATAL_FAILURE( 274 ASSERT_NO_FATAL_FAILURE(
269 CreateChannel(kTestChannelName, &host_socket1_, &client_socket1_)); 275 CreateChannel(kTestChannelName, &host_socket1_, &client_socket1_));
270 276
271 ASSERT_NO_FATAL_FAILURE( 277 ASSERT_NO_FATAL_FAILURE(
272 CreateChannel(kTestChannelName2, &host_socket2_, &client_socket2_)); 278 CreateChannel(kTestChannelName2, &host_socket2_, &client_socket2_));
273 279
274 ConnectSockets(); 280 ConnectSockets();
275 281
276 host_session_.GetStreamChannel(kMuxChannelName)-> 282 host_session_.GetStreamChannel(kMuxChannelName)->
277 set_next_write_error(net::ERR_FAILED); 283 set_next_write_error(net::ERR_FAILED);
278 host_session_.GetStreamChannel(kMuxChannelName)-> 284 host_session_.GetStreamChannel(kMuxChannelName)->
279 set_async_write(true); 285 set_async_write(true);
280 286
281 scoped_refptr<net::IOBufferWithSize> buf = CreateTestBuffer(100); 287 scoped_refptr<net::IOBufferWithSize> buf = CreateTestBuffer(100);
282 288
283 MockSocketCallback cb1; 289 MockSocketCallback cb1;
284 MockSocketCallback cb2; 290 MockSocketCallback cb2;
285 EXPECT_CALL(cb1, OnDone(net::ERR_FAILED)); 291 EXPECT_CALL(cb1, OnDone(net::ERR_FAILED));
286 EXPECT_CALL(cb2, OnDone(net::ERR_FAILED)); 292 EXPECT_CALL(cb2, OnDone(net::ERR_FAILED));
287 293
288 EXPECT_EQ(net::ERR_IO_PENDING, 294 EXPECT_EQ(net::ERR_IO_PENDING,
289 host_socket1_->Write(buf, buf->size(), base::Bind( 295 host_socket1_->Write(buf.get(),
290 &MockSocketCallback::OnDone, base::Unretained(&cb1)))); 296 buf->size(),
297 base::Bind(&MockSocketCallback::OnDone,
298 base::Unretained(&cb1))));
291 EXPECT_EQ(net::ERR_IO_PENDING, 299 EXPECT_EQ(net::ERR_IO_PENDING,
292 host_socket2_->Write(buf, buf->size(), base::Bind( 300 host_socket2_->Write(buf.get(),
293 &MockSocketCallback::OnDone, base::Unretained(&cb2)))); 301 buf->size(),
302 base::Bind(&MockSocketCallback::OnDone,
303 base::Unretained(&cb2))));
294 304
295 message_loop_.RunUntilIdle(); 305 message_loop_.RunUntilIdle();
296 } 306 }
297 307
298 TEST_F(ChannelMultiplexerTest, DeleteWhenFailed) { 308 TEST_F(ChannelMultiplexerTest, DeleteWhenFailed) {
299 ASSERT_NO_FATAL_FAILURE( 309 ASSERT_NO_FATAL_FAILURE(
300 CreateChannel(kTestChannelName, &host_socket1_, &client_socket1_)); 310 CreateChannel(kTestChannelName, &host_socket1_, &client_socket1_));
301 ASSERT_NO_FATAL_FAILURE( 311 ASSERT_NO_FATAL_FAILURE(
302 CreateChannel(kTestChannelName2, &host_socket2_, &client_socket2_)); 312 CreateChannel(kTestChannelName2, &host_socket2_, &client_socket2_));
303 313
(...skipping 10 matching lines...) Expand all
314 MockSocketCallback cb2; 324 MockSocketCallback cb2;
315 325
316 EXPECT_CALL(cb1, OnDone(net::ERR_FAILED)) 326 EXPECT_CALL(cb1, OnDone(net::ERR_FAILED))
317 .Times(AtMost(1)) 327 .Times(AtMost(1))
318 .WillOnce(InvokeWithoutArgs(this, &ChannelMultiplexerTest::DeleteAll)); 328 .WillOnce(InvokeWithoutArgs(this, &ChannelMultiplexerTest::DeleteAll));
319 EXPECT_CALL(cb2, OnDone(net::ERR_FAILED)) 329 EXPECT_CALL(cb2, OnDone(net::ERR_FAILED))
320 .Times(AtMost(1)) 330 .Times(AtMost(1))
321 .WillOnce(InvokeWithoutArgs(this, &ChannelMultiplexerTest::DeleteAll)); 331 .WillOnce(InvokeWithoutArgs(this, &ChannelMultiplexerTest::DeleteAll));
322 332
323 EXPECT_EQ(net::ERR_IO_PENDING, 333 EXPECT_EQ(net::ERR_IO_PENDING,
324 host_socket1_->Write(buf, buf->size(), base::Bind( 334 host_socket1_->Write(buf.get(),
325 &MockSocketCallback::OnDone, base::Unretained(&cb1)))); 335 buf->size(),
336 base::Bind(&MockSocketCallback::OnDone,
337 base::Unretained(&cb1))));
326 EXPECT_EQ(net::ERR_IO_PENDING, 338 EXPECT_EQ(net::ERR_IO_PENDING,
327 host_socket2_->Write(buf, buf->size(), base::Bind( 339 host_socket2_->Write(buf.get(),
328 &MockSocketCallback::OnDone, base::Unretained(&cb2)))); 340 buf->size(),
341 base::Bind(&MockSocketCallback::OnDone,
342 base::Unretained(&cb2))));
329 343
330 message_loop_.RunUntilIdle(); 344 message_loop_.RunUntilIdle();
331 345
332 // Check that the sockets were destroyed. 346 // Check that the sockets were destroyed.
333 EXPECT_FALSE(host_mux_.get()); 347 EXPECT_FALSE(host_mux_.get());
334 } 348 }
335 349
336 TEST_F(ChannelMultiplexerTest, SessionFail) { 350 TEST_F(ChannelMultiplexerTest, SessionFail) {
337 host_session_.set_async_creation(true); 351 host_session_.set_async_creation(true);
338 host_session_.set_error(AUTHENTICATION_FAILED); 352 host_session_.set_error(AUTHENTICATION_FAILED);
(...skipping 11 matching lines...) Expand all
350 .WillOnce(InvokeWithoutArgs( 364 .WillOnce(InvokeWithoutArgs(
351 this, &ChannelMultiplexerTest::DeleteAfterSessionFail)); 365 this, &ChannelMultiplexerTest::DeleteAfterSessionFail));
352 EXPECT_CALL(cb2, OnConnectedPtr(_)) 366 EXPECT_CALL(cb2, OnConnectedPtr(_))
353 .Times(0); 367 .Times(0);
354 368
355 message_loop_.RunUntilIdle(); 369 message_loop_.RunUntilIdle();
356 } 370 }
357 371
358 } // namespace protocol 372 } // namespace protocol
359 } // namespace remoting 373 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/channel_multiplexer.cc ('k') | remoting/protocol/connection_tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698