| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); | 144 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); |
| 145 FakeSignalStrategy::Connect(host_signal_strategy_.get(), | 145 FakeSignalStrategy::Connect(host_signal_strategy_.get(), |
| 146 client_signal_strategy_.get()); | 146 client_signal_strategy_.get()); |
| 147 | 147 |
| 148 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) | 148 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) |
| 149 .Times(1); | 149 .Times(1); |
| 150 | 150 |
| 151 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING); | 151 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING); |
| 152 | 152 |
| 153 scoped_ptr<TransportFactory> host_transport(new LibjingleTransportFactory( | 153 scoped_ptr<TransportFactory> host_transport(new LibjingleTransportFactory( |
| 154 NULL, | 154 nullptr, |
| 155 ChromiumPortAllocator::Create(NULL, network_settings).Pass(), | 155 ChromiumPortAllocator::Create(nullptr, network_settings).Pass(), |
| 156 network_settings)); | 156 network_settings)); |
| 157 host_server_.reset(new JingleSessionManager(host_transport.Pass())); | 157 host_server_.reset(new JingleSessionManager(host_transport.Pass())); |
| 158 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_); | 158 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_); |
| 159 | 159 |
| 160 scoped_ptr<AuthenticatorFactory> factory( | 160 scoped_ptr<AuthenticatorFactory> factory( |
| 161 new FakeHostAuthenticatorFactory(auth_round_trips, | 161 new FakeHostAuthenticatorFactory(auth_round_trips, |
| 162 messages_till_start, auth_action, true)); | 162 messages_till_start, auth_action, true)); |
| 163 host_server_->set_authenticator_factory(factory.Pass()); | 163 host_server_->set_authenticator_factory(factory.Pass()); |
| 164 | 164 |
| 165 EXPECT_CALL(client_server_listener_, OnSessionManagerReady()) | 165 EXPECT_CALL(client_server_listener_, OnSessionManagerReady()) |
| 166 .Times(1); | 166 .Times(1); |
| 167 scoped_ptr<TransportFactory> client_transport(new LibjingleTransportFactory( | 167 scoped_ptr<TransportFactory> client_transport(new LibjingleTransportFactory( |
| 168 NULL, | 168 nullptr, |
| 169 ChromiumPortAllocator::Create(NULL, network_settings).Pass(), | 169 ChromiumPortAllocator::Create(nullptr, network_settings).Pass(), |
| 170 network_settings)); | 170 network_settings)); |
| 171 client_server_.reset( | 171 client_server_.reset( |
| 172 new JingleSessionManager(client_transport.Pass())); | 172 new JingleSessionManager(client_transport.Pass())); |
| 173 client_server_->Init(client_signal_strategy_.get(), | 173 client_server_->Init(client_signal_strategy_.get(), |
| 174 &client_server_listener_); | 174 &client_server_listener_); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void CreateSessionManagers(int auth_round_trips, | 177 void CreateSessionManagers(int auth_round_trips, |
| 178 FakeAuthenticator::Action auth_action) { | 178 FakeAuthenticator::Action auth_action) { |
| 179 CreateSessionManagers(auth_round_trips, 0, auth_action); | 179 CreateSessionManagers(auth_round_trips, 0, auth_action); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 | 499 |
| 500 client_session_->GetTransportChannelFactory()->CreateChannel( | 500 client_session_->GetTransportChannelFactory()->CreateChannel( |
| 501 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, | 501 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, |
| 502 base::Unretained(this))); | 502 base::Unretained(this))); |
| 503 host_session_->GetTransportChannelFactory()->CreateChannel( | 503 host_session_->GetTransportChannelFactory()->CreateChannel( |
| 504 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, | 504 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated, |
| 505 base::Unretained(this))); | 505 base::Unretained(this))); |
| 506 | 506 |
| 507 // Terminate the message loop when we get rejection notification | 507 // Terminate the message loop when we get rejection notification |
| 508 // from the host. | 508 // from the host. |
| 509 EXPECT_CALL(host_channel_callback_, OnDone(NULL)) | 509 EXPECT_CALL(host_channel_callback_, OnDone(nullptr)) |
| 510 .WillOnce(QuitThread()); | 510 .WillOnce(QuitThread()); |
| 511 ExpectRouteChange(kChannelName); | 511 ExpectRouteChange(kChannelName); |
| 512 | 512 |
| 513 message_loop_->Run(); | 513 message_loop_->Run(); |
| 514 | 514 |
| 515 client_session_->GetTransportChannelFactory()->CancelChannelCreation( | 515 client_session_->GetTransportChannelFactory()->CancelChannelCreation( |
| 516 kChannelName); | 516 kChannelName); |
| 517 | 517 |
| 518 EXPECT_TRUE(!host_socket_.get()); | 518 EXPECT_TRUE(!host_socket_.get()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 TEST_F(JingleSessionTest, TestCancelChannelCreation) { | 521 TEST_F(JingleSessionTest, TestCancelChannelCreation) { |
| 522 CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL); | 522 CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL); |
| 523 ASSERT_NO_FATAL_FAILURE( | 523 ASSERT_NO_FATAL_FAILURE( |
| 524 InitiateConnection(1, FakeAuthenticator::ACCEPT, false)); | 524 InitiateConnection(1, FakeAuthenticator::ACCEPT, false)); |
| 525 | 525 |
| 526 client_session_->GetTransportChannelFactory()->CreateChannel( | 526 client_session_->GetTransportChannelFactory()->CreateChannel( |
| 527 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, | 527 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated, |
| 528 base::Unretained(this))); | 528 base::Unretained(this))); |
| 529 client_session_->GetTransportChannelFactory()->CancelChannelCreation( | 529 client_session_->GetTransportChannelFactory()->CancelChannelCreation( |
| 530 kChannelName); | 530 kChannelName); |
| 531 | 531 |
| 532 EXPECT_TRUE(!client_socket_.get()); | 532 EXPECT_TRUE(!client_socket_.get()); |
| 533 } | 533 } |
| 534 | 534 |
| 535 } // namespace protocol | 535 } // namespace protocol |
| 536 } // namespace remoting | 536 } // namespace remoting |
| OLD | NEW |