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/jingle_session.h" | 5 #include "remoting/protocol/jingle_session.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 "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 EXPECT_TRUE(client_socket_.get()); | 518 EXPECT_TRUE(client_socket_.get()); |
519 EXPECT_TRUE(host_socket_.get()); | 519 EXPECT_TRUE(host_socket_.get()); |
520 | 520 |
521 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | 521 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
522 kMessageSize, kMessages); | 522 kMessageSize, kMessages); |
523 tester.Start(); | 523 tester.Start(); |
524 message_loop_->Run(); | 524 message_loop_->Run(); |
525 tester.CheckResults(); | 525 tester.CheckResults(); |
526 } | 526 } |
527 | 527 |
528 // Verify that data can be sent over a QUIC channel. | |
529 TEST_F(JingleSessionTest, TestQuicStreamChannel) { | |
530 CreateSessionManagers(1, FakeAuthenticator::ACCEPT); | |
531 | |
532 scoped_ptr<CandidateSessionConfig> config = | |
533 CandidateSessionConfig::CreateDefault(); | |
534 config->PreferTransport(ChannelConfig::TRANSPORT_QUIC_STREAM); | |
535 client_server_->set_protocol_config(config.Pass()); | |
536 | |
537 ExpectRouteChange(kQuicChannelName); | |
538 | |
539 ASSERT_NO_FATAL_FAILURE( | |
540 InitiateConnection(1, FakeAuthenticator::ACCEPT, false)); | |
541 | |
542 int counter = 2; | |
543 EXPECT_CALL(client_channel_callback_, OnDone(_)) | |
544 .WillOnce(QuitThreadOnCounter(&counter)); | |
545 EXPECT_CALL(host_channel_callback_, OnDone(_)) | |
546 .WillOnce(QuitThreadOnCounter(&counter)); | |
547 | |
548 client_session_->GetQuicChannelFactory()->CreateChannel( | |
549 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, | |
550 base::Unretained(this))); | |
551 host_session_->GetQuicChannelFactory()->CreateChannel( | |
552 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, | |
553 base::Unretained(this))); | |
554 | |
555 message_loop_->Run(); | |
556 | |
557 EXPECT_TRUE(client_socket_.get()); | |
558 EXPECT_TRUE(host_socket_.get()); | |
559 | |
560 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | |
561 kMessageSize, kMessages); | |
562 tester.Start(); | |
563 message_loop_->Run(); | |
564 tester.CheckResults(); | |
565 } | |
566 | |
567 // Verify that channels are never marked connected if transport is broken. | 528 // Verify that channels are never marked connected if transport is broken. |
568 TEST_F(JingleSessionTest, TestBrokenTransport) { | 529 TEST_F(JingleSessionTest, TestBrokenTransport) { |
569 // Allow only incoming connections on both ends, which effectively renders P2P | 530 // Allow only incoming connections on both ends, which effectively renders P2P |
570 // transport unusable as. | 531 // transport unusable. |
571 network_settings_ = NetworkSettings(NetworkSettings::NAT_TRAVERSAL_DISABLED); | 532 network_settings_ = NetworkSettings(NetworkSettings::NAT_TRAVERSAL_DISABLED); |
572 CreateSessionManagers(1, FakeAuthenticator::ACCEPT); | 533 CreateSessionManagers(1, FakeAuthenticator::ACCEPT); |
573 | 534 |
574 scoped_ptr<CandidateSessionConfig> config = | 535 scoped_ptr<CandidateSessionConfig> config = |
575 CandidateSessionConfig::CreateDefault(); | 536 CandidateSessionConfig::CreateDefault(); |
576 config->PreferTransport(ChannelConfig::TRANSPORT_QUIC_STREAM); | 537 config->PreferTransport(ChannelConfig::TRANSPORT_MUX_STREAM); |
577 client_server_->set_protocol_config(config.Pass()); | 538 client_server_->set_protocol_config(config.Pass()); |
578 | 539 |
579 ASSERT_NO_FATAL_FAILURE( | 540 ASSERT_NO_FATAL_FAILURE( |
580 InitiateConnection(1, FakeAuthenticator::ACCEPT, false)); | 541 InitiateConnection(1, FakeAuthenticator::ACCEPT, false)); |
581 | 542 |
582 EXPECT_CALL(client_channel_callback_, OnDone(_)).Times(0); | 543 EXPECT_CALL(client_channel_callback_, OnDone(_)).Times(0); |
583 EXPECT_CALL(host_channel_callback_, OnDone(_)).Times(0); | 544 EXPECT_CALL(host_channel_callback_, OnDone(_)).Times(0); |
584 | 545 |
585 client_session_->GetQuicChannelFactory()->CreateChannel( | 546 client_session_->GetTransport() |
586 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, | 547 ->GetMultiplexedChannelFactory() |
587 base::Unretained(this))); | 548 ->CreateChannel(kChannelName, |
588 host_session_->GetQuicChannelFactory()->CreateChannel( | 549 base::Bind(&JingleSessionTest::OnClientChannelCreated, |
| 550 base::Unretained(this))); |
| 551 host_session_->GetTransport()->GetMultiplexedChannelFactory()->CreateChannel( |
589 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, | 552 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, |
590 base::Unretained(this))); | 553 base::Unretained(this))); |
591 | 554 |
592 message_loop_->RunUntilIdle(); | 555 message_loop_->RunUntilIdle(); |
593 | 556 |
594 // Verify that neither of the two ends of the channel is connected. | 557 // Verify that neither of the two ends of the channel is connected. |
595 EXPECT_FALSE(client_socket_); | 558 EXPECT_FALSE(client_socket_); |
596 EXPECT_FALSE(host_socket_); | 559 EXPECT_FALSE(host_socket_); |
597 | 560 |
598 client_session_->GetQuicChannelFactory()->CancelChannelCreation(kChannelName); | 561 client_session_->GetTransport() |
599 host_session_->GetQuicChannelFactory()->CancelChannelCreation(kChannelName); | 562 ->GetMultiplexedChannelFactory() |
| 563 ->CancelChannelCreation(kChannelName); |
| 564 host_session_->GetTransport() |
| 565 ->GetMultiplexedChannelFactory() |
| 566 ->CancelChannelCreation(kChannelName); |
600 } | 567 } |
601 | 568 |
602 // Verify that we can connect channels with multistep auth. | 569 // Verify that we can connect channels with multistep auth. |
603 TEST_F(JingleSessionTest, TestMultistepAuthStreamChannel) { | 570 TEST_F(JingleSessionTest, TestMultistepAuthStreamChannel) { |
604 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); | 571 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); |
605 ASSERT_NO_FATAL_FAILURE( | 572 ASSERT_NO_FATAL_FAILURE( |
606 InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); | 573 InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); |
607 | 574 |
608 ASSERT_NO_FATAL_FAILURE(CreateChannel()); | 575 ASSERT_NO_FATAL_FAILURE(CreateChannel()); |
609 | 576 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 | 640 |
674 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | 641 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
675 kMessageSize, 1); | 642 kMessageSize, 1); |
676 tester.Start(); | 643 tester.Start(); |
677 message_loop_->Run(); | 644 message_loop_->Run(); |
678 tester.CheckResults(); | 645 tester.CheckResults(); |
679 } | 646 } |
680 | 647 |
681 } // namespace protocol | 648 } // namespace protocol |
682 } // namespace remoting | 649 } // namespace remoting |
OLD | NEW |