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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 client_session_.reset(); | 96 client_session_.reset(); |
96 } | 97 } |
97 | 98 |
98 void CreateSessionManagers(int auth_round_trips, int messages_till_start, | 99 void CreateSessionManagers(int auth_round_trips, int messages_till_start, |
99 FakeAuthenticator::Action auth_action) { | 100 FakeAuthenticator::Action auth_action) { |
100 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); | 101 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); |
101 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); | 102 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); |
102 FakeSignalStrategy::Connect(host_signal_strategy_.get(), | 103 FakeSignalStrategy::Connect(host_signal_strategy_.get(), |
103 client_signal_strategy_.get()); | 104 client_signal_strategy_.get()); |
104 | 105 |
105 scoped_ptr<TransportFactory> host_transport(new IceTransportFactory( | 106 host_server_.reset(new JingleSessionManager( |
106 nullptr, | 107 make_scoped_ptr(new IceTransportFactory(new TransportContext( |
107 ChromiumPortAllocator::Create(nullptr, network_settings_).Pass(), | 108 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)), |
108 network_settings_, TransportRole::SERVER)); | 109 network_settings_, TransportRole::SERVER))))); |
109 host_server_.reset(new JingleSessionManager(host_transport.Pass())); | |
110 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_); | 110 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_); |
111 | 111 |
112 scoped_ptr<AuthenticatorFactory> factory( | 112 scoped_ptr<AuthenticatorFactory> factory( |
113 new FakeHostAuthenticatorFactory(auth_round_trips, | 113 new FakeHostAuthenticatorFactory(auth_round_trips, |
114 messages_till_start, auth_action, true)); | 114 messages_till_start, auth_action, true)); |
115 host_server_->set_authenticator_factory(factory.Pass()); | 115 host_server_->set_authenticator_factory(factory.Pass()); |
116 | 116 |
117 scoped_ptr<TransportFactory> client_transport(new IceTransportFactory( | 117 client_server_.reset(new JingleSessionManager( |
118 nullptr, | 118 make_scoped_ptr(new IceTransportFactory(new TransportContext( |
119 ChromiumPortAllocator::Create(nullptr, network_settings_).Pass(), | 119 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)), |
120 network_settings_, TransportRole::CLIENT)); | 120 network_settings_, TransportRole::CLIENT))))); |
121 client_server_.reset( | |
122 new JingleSessionManager(client_transport.Pass())); | |
123 client_server_->Init(client_signal_strategy_.get(), | 121 client_server_->Init(client_signal_strategy_.get(), |
124 &client_server_listener_); | 122 &client_server_listener_); |
125 } | 123 } |
126 | 124 |
127 void CreateSessionManagers(int auth_round_trips, | 125 void CreateSessionManagers(int auth_round_trips, |
128 FakeAuthenticator::Action auth_action) { | 126 FakeAuthenticator::Action auth_action) { |
129 CreateSessionManagers(auth_round_trips, 0, auth_action); | 127 CreateSessionManagers(auth_round_trips, 0, auth_action); |
130 } | 128 } |
131 | 129 |
132 void CloseSessionManager() { | 130 void CloseSessionManager() { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 402 |
405 // Verify that we can connect with multistep authentication. | 403 // Verify that we can connect with multistep authentication. |
406 TEST_F(JingleSessionTest, TestMultistepAuth) { | 404 TEST_F(JingleSessionTest, TestMultistepAuth) { |
407 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); | 405 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); |
408 ASSERT_NO_FATAL_FAILURE( | 406 ASSERT_NO_FATAL_FAILURE( |
409 InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); | 407 InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); |
410 } | 408 } |
411 | 409 |
412 } // namespace protocol | 410 } // namespace protocol |
413 } // namespace remoting | 411 } // namespace remoting |
OLD | NEW |