| 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" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "jingle/glue/thread_wrapper.h" | 12 #include "jingle/glue/thread_wrapper.h" |
| 13 #include "net/socket/socket.h" | 13 #include "net/socket/socket.h" |
| 14 #include "net/socket/stream_socket.h" | 14 #include "net/socket/stream_socket.h" |
| 15 #include "net/url_request/url_request_context_getter.h" | 15 #include "net/url_request/url_request_context_getter.h" |
| 16 #include "remoting/base/constants.h" | 16 #include "remoting/base/constants.h" |
| 17 #include "remoting/protocol/authenticator.h" | 17 #include "remoting/protocol/authenticator.h" |
| 18 #include "remoting/protocol/channel_authenticator.h" | 18 #include "remoting/protocol/channel_authenticator.h" |
| 19 #include "remoting/protocol/chromium_port_allocator.h" | 19 #include "remoting/protocol/chromium_port_allocator.h" |
| 20 #include "remoting/protocol/connection_tester.h" | 20 #include "remoting/protocol/connection_tester.h" |
| 21 #include "remoting/protocol/fake_authenticator.h" | 21 #include "remoting/protocol/fake_authenticator.h" |
| 22 #include "remoting/protocol/ice_transport_factory.h" | 22 #include "remoting/protocol/ice_transport.h" |
| 23 #include "remoting/protocol/jingle_session_manager.h" | 23 #include "remoting/protocol/jingle_session_manager.h" |
| 24 #include "remoting/protocol/network_settings.h" | 24 #include "remoting/protocol/network_settings.h" |
| 25 #include "remoting/protocol/transport_context.h" |
| 25 #include "remoting/signaling/fake_signal_strategy.h" | 26 #include "remoting/signaling/fake_signal_strategy.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 29 |
| 29 using testing::_; | 30 using testing::_; |
| 30 using testing::AtLeast; | 31 using testing::AtLeast; |
| 31 using testing::AtMost; | 32 using testing::AtMost; |
| 32 using testing::DeleteArg; | 33 using testing::DeleteArg; |
| 33 using testing::DoAll; | 34 using testing::DoAll; |
| 34 using testing::InSequence; | 35 using testing::InSequence; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void CreateSessionManagers(int auth_round_trips, int messages_till_start, | 100 void CreateSessionManagers(int auth_round_trips, int messages_till_start, |
| 100 FakeAuthenticator::Action auth_action) { | 101 FakeAuthenticator::Action auth_action) { |
| 101 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); | 102 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); |
| 102 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); | 103 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); |
| 103 FakeSignalStrategy::Connect(host_signal_strategy_.get(), | 104 FakeSignalStrategy::Connect(host_signal_strategy_.get(), |
| 104 client_signal_strategy_.get()); | 105 client_signal_strategy_.get()); |
| 105 | 106 |
| 106 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) | 107 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) |
| 107 .Times(1); | 108 .Times(1); |
| 108 | 109 |
| 109 scoped_ptr<TransportFactory> host_transport(new IceTransportFactory( | 110 host_server_.reset(new JingleSessionManager( |
| 110 nullptr, | 111 make_scoped_ptr(new IceTransportFactory(new TransportContext( |
| 111 ChromiumPortAllocator::Create(nullptr, network_settings_).Pass(), | 112 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)), |
| 112 network_settings_, TransportRole::SERVER)); | 113 network_settings_, TransportRole::SERVER))))); |
| 113 host_server_.reset(new JingleSessionManager(host_transport.Pass())); | |
| 114 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_); | 114 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_); |
| 115 | 115 |
| 116 scoped_ptr<AuthenticatorFactory> factory( | 116 scoped_ptr<AuthenticatorFactory> factory( |
| 117 new FakeHostAuthenticatorFactory(auth_round_trips, | 117 new FakeHostAuthenticatorFactory(auth_round_trips, |
| 118 messages_till_start, auth_action, true)); | 118 messages_till_start, auth_action, true)); |
| 119 host_server_->set_authenticator_factory(factory.Pass()); | 119 host_server_->set_authenticator_factory(factory.Pass()); |
| 120 | 120 |
| 121 EXPECT_CALL(client_server_listener_, OnSessionManagerReady()) | 121 EXPECT_CALL(client_server_listener_, OnSessionManagerReady()) |
| 122 .Times(1); | 122 .Times(1); |
| 123 scoped_ptr<TransportFactory> client_transport(new IceTransportFactory( | 123 client_server_.reset(new JingleSessionManager( |
| 124 nullptr, | 124 make_scoped_ptr(new IceTransportFactory(new TransportContext( |
| 125 ChromiumPortAllocator::Create(nullptr, network_settings_).Pass(), | 125 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)), |
| 126 network_settings_, TransportRole::CLIENT)); | 126 network_settings_, TransportRole::CLIENT))))); |
| 127 client_server_.reset( | |
| 128 new JingleSessionManager(client_transport.Pass())); | |
| 129 client_server_->Init(client_signal_strategy_.get(), | 127 client_server_->Init(client_signal_strategy_.get(), |
| 130 &client_server_listener_); | 128 &client_server_listener_); |
| 131 } | 129 } |
| 132 | 130 |
| 133 void CreateSessionManagers(int auth_round_trips, | 131 void CreateSessionManagers(int auth_round_trips, |
| 134 FakeAuthenticator::Action auth_action) { | 132 FakeAuthenticator::Action auth_action) { |
| 135 CreateSessionManagers(auth_round_trips, 0, auth_action); | 133 CreateSessionManagers(auth_round_trips, 0, auth_action); |
| 136 } | 134 } |
| 137 | 135 |
| 138 void CloseSessionManager() { | 136 void CloseSessionManager() { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 408 |
| 411 // Verify that we can connect with multistep authentication. | 409 // Verify that we can connect with multistep authentication. |
| 412 TEST_F(JingleSessionTest, TestMultistepAuth) { | 410 TEST_F(JingleSessionTest, TestMultistepAuth) { |
| 413 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); | 411 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); |
| 414 ASSERT_NO_FATAL_FAILURE( | 412 ASSERT_NO_FATAL_FAILURE( |
| 415 InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); | 413 InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); |
| 416 } | 414 } |
| 417 | 415 |
| 418 } // namespace protocol | 416 } // namespace protocol |
| 419 } // namespace remoting | 417 } // namespace remoting |
| OLD | NEW |