OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ice_transport.h" | 5 #include "remoting/protocol/ice_transport.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 115 } |
116 | 116 |
117 void InitializeConnection() { | 117 void InitializeConnection() { |
118 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 118 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
119 | 119 |
120 host_transport_.reset(new IceTransport( | 120 host_transport_.reset(new IceTransport( |
121 new TransportContext(nullptr, | 121 new TransportContext(nullptr, |
122 base::MakeUnique<ChromiumPortAllocatorFactory>(), | 122 base::MakeUnique<ChromiumPortAllocatorFactory>(), |
123 nullptr, network_settings_, TransportRole::SERVER), | 123 nullptr, network_settings_, TransportRole::SERVER), |
124 &host_event_handler_)); | 124 &host_event_handler_)); |
125 if (!host_authenticator_) { | 125 host_authenticator_.reset(new FakeAuthenticator(FakeAuthenticator::ACCEPT)); |
126 host_authenticator_.reset(new FakeAuthenticator( | |
127 FakeAuthenticator::HOST, 0, FakeAuthenticator::ACCEPT, true)); | |
128 } | |
129 | 126 |
130 client_transport_.reset(new IceTransport( | 127 client_transport_.reset(new IceTransport( |
131 new TransportContext(nullptr, | 128 new TransportContext(nullptr, |
132 base::MakeUnique<ChromiumPortAllocatorFactory>(), | 129 base::MakeUnique<ChromiumPortAllocatorFactory>(), |
133 nullptr, network_settings_, TransportRole::CLIENT), | 130 nullptr, network_settings_, TransportRole::CLIENT), |
134 &client_event_handler_)); | 131 &client_event_handler_)); |
135 if (!client_authenticator_) { | 132 client_authenticator_.reset( |
136 client_authenticator_.reset(new FakeAuthenticator( | 133 new FakeAuthenticator(FakeAuthenticator::ACCEPT)); |
137 FakeAuthenticator::CLIENT, 0, FakeAuthenticator::ACCEPT, true)); | |
138 } | |
139 | 134 |
140 host_event_handler_.set_error_callback(base::Bind( | 135 host_event_handler_.set_error_callback(base::Bind( |
141 &IceTransportTest::OnTransportError, base::Unretained(this))); | 136 &IceTransportTest::OnTransportError, base::Unretained(this))); |
142 client_event_handler_.set_error_callback(base::Bind( | 137 client_event_handler_.set_error_callback(base::Bind( |
143 &IceTransportTest::OnTransportError, base::Unretained(this))); | 138 &IceTransportTest::OnTransportError, base::Unretained(this))); |
144 | 139 |
145 // Start both transports. | 140 // Start both transports. |
146 host_transport_->Start( | 141 host_transport_->Start( |
147 host_authenticator_.get(), | 142 host_authenticator_.get(), |
148 base::Bind(&IceTransportTest::ProcessTransportInfo, | 143 base::Bind(&IceTransportTest::ProcessTransportInfo, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 WaitUntilConnected(); | 235 WaitUntilConnected(); |
241 | 236 |
242 MessagePipeConnectionTester tester(host_message_pipe_.get(), | 237 MessagePipeConnectionTester tester(host_message_pipe_.get(), |
243 client_message_pipe_.get(), kMessageSize, | 238 client_message_pipe_.get(), kMessageSize, |
244 kMessages); | 239 kMessages); |
245 tester.RunAndCheckResults(); | 240 tester.RunAndCheckResults(); |
246 } | 241 } |
247 | 242 |
248 TEST_F(IceTransportTest, FailedChannelAuth) { | 243 TEST_F(IceTransportTest, FailedChannelAuth) { |
249 // Use host authenticator with one that rejects channel authentication. | 244 // Use host authenticator with one that rejects channel authentication. |
250 host_authenticator_.reset(new FakeAuthenticator( | 245 host_authenticator_.reset( |
251 FakeAuthenticator::HOST, 0, FakeAuthenticator::REJECT_CHANNEL, true)); | 246 new FakeAuthenticator(FakeAuthenticator::REJECT_CHANNEL)); |
252 | 247 |
253 InitializeConnection(); | 248 InitializeConnection(); |
254 | 249 |
255 client_transport_->GetChannelFactory()->CreateChannel( | 250 client_transport_->GetChannelFactory()->CreateChannel( |
256 kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated, | 251 kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated, |
257 base::Unretained(this))); | 252 base::Unretained(this))); |
258 host_transport_->GetChannelFactory()->CreateChannel( | 253 host_transport_->GetChannelFactory()->CreateChannel( |
259 kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated, | 254 kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated, |
260 base::Unretained(this))); | 255 base::Unretained(this))); |
261 | 256 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 332 |
338 MessagePipeConnectionTester tester(host_message_pipe_.get(), | 333 MessagePipeConnectionTester tester(host_message_pipe_.get(), |
339 client_message_pipe_.get(), kMessageSize, | 334 client_message_pipe_.get(), kMessageSize, |
340 kMessages); | 335 kMessages); |
341 tester.RunAndCheckResults(); | 336 tester.RunAndCheckResults(); |
342 } | 337 } |
343 | 338 |
344 | 339 |
345 } // namespace protocol | 340 } // namespace protocol |
346 } // namespace remoting | 341 } // namespace remoting |
OLD | NEW |