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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "net/socket/socket.h" | 9 #include "net/socket/socket.h" |
10 #include "net/socket/stream_socket.h" | 10 #include "net/socket/stream_socket.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 EXPECT_CALL(client_connection_callback_, | 199 EXPECT_CALL(client_connection_callback_, |
200 OnStateChange(Session::FAILED)) | 200 OnStateChange(Session::FAILED)) |
201 .Times(1); | 201 .Times(1); |
202 } else { | 202 } else { |
203 EXPECT_CALL(client_connection_callback_, | 203 EXPECT_CALL(client_connection_callback_, |
204 OnStateChange(Session::AUTHENTICATED)) | 204 OnStateChange(Session::AUTHENTICATED)) |
205 .Times(1); | 205 .Times(1); |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 Authenticator* authenticator = new FakeAuthenticator( | 209 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator( |
210 FakeAuthenticator::CLIENT, auth_round_trips, auth_action, true); | 210 FakeAuthenticator::CLIENT, auth_round_trips, auth_action, true)); |
211 | 211 |
212 client_session_.reset(client_server_->Connect( | 212 client_session_ = client_server_->Connect( |
213 kHostJid, authenticator, | 213 kHostJid, authenticator.Pass(), |
214 CandidateSessionConfig::CreateDefault(), | 214 CandidateSessionConfig::CreateDefault(), |
215 base::Bind(&MockSessionCallback::OnStateChange, | 215 base::Bind(&MockSessionCallback::OnStateChange, |
216 base::Unretained(&client_connection_callback_)))); | 216 base::Unretained(&client_connection_callback_))); |
217 | 217 |
218 message_loop_.RunAllPending(); | 218 message_loop_.RunAllPending(); |
219 | 219 |
220 Mock::VerifyAndClearExpectations(&host_connection_callback_); | 220 Mock::VerifyAndClearExpectations(&host_connection_callback_); |
221 Mock::VerifyAndClearExpectations(&client_connection_callback_); | 221 Mock::VerifyAndClearExpectations(&client_connection_callback_); |
222 | 222 |
223 if (!expect_fail) { | 223 if (!expect_fail) { |
224 // Expect that the connection will be closed eventually. | 224 // Expect that the connection will be closed eventually. |
225 EXPECT_CALL(host_connection_callback_, | 225 EXPECT_CALL(host_connection_callback_, |
226 OnStateChange(Session::CLOSED)) | 226 OnStateChange(Session::CLOSED)) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 InSequence dummy; | 301 InSequence dummy; |
302 | 302 |
303 EXPECT_CALL(client_connection_callback_, | 303 EXPECT_CALL(client_connection_callback_, |
304 OnStateChange(Session::CONNECTING)) | 304 OnStateChange(Session::CONNECTING)) |
305 .Times(1); | 305 .Times(1); |
306 EXPECT_CALL(client_connection_callback_, | 306 EXPECT_CALL(client_connection_callback_, |
307 OnStateChange(Session::FAILED)) | 307 OnStateChange(Session::FAILED)) |
308 .Times(1); | 308 .Times(1); |
309 } | 309 } |
310 | 310 |
311 Authenticator* authenticator = new FakeAuthenticator( | 311 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator( |
312 FakeAuthenticator::CLIENT, 1, FakeAuthenticator::ACCEPT, true); | 312 FakeAuthenticator::CLIENT, 1, FakeAuthenticator::ACCEPT, true)); |
313 client_session_.reset(client_server_->Connect( | 313 client_session_ = client_server_->Connect( |
314 kHostJid, authenticator, | 314 kHostJid, authenticator.Pass(), CandidateSessionConfig::CreateDefault(), |
315 CandidateSessionConfig::CreateDefault(), | |
316 base::Bind(&MockSessionCallback::OnStateChange, | 315 base::Bind(&MockSessionCallback::OnStateChange, |
317 base::Unretained(&client_connection_callback_)))); | 316 base::Unretained(&client_connection_callback_))); |
318 | 317 |
319 message_loop_.RunAllPending(); | 318 message_loop_.RunAllPending(); |
320 } | 319 } |
321 | 320 |
322 // Verify that we can connect two endpoints with single-step authentication. | 321 // Verify that we can connect two endpoints with single-step authentication. |
323 TEST_F(JingleSessionTest, Connect) { | 322 TEST_F(JingleSessionTest, Connect) { |
324 CreateSessionManagers(1, FakeAuthenticator::ACCEPT); | 323 CreateSessionManagers(1, FakeAuthenticator::ACCEPT); |
325 InitiateConnection(1, FakeAuthenticator::ACCEPT, false); | 324 InitiateConnection(1, FakeAuthenticator::ACCEPT, false); |
326 } | 325 } |
327 | 326 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 435 |
437 DatagramConnectionTester tester( | 436 DatagramConnectionTester tester( |
438 client_socket, host_socket, kMessageSize, kMessages, kUdpWriteDelayMs); | 437 client_socket, host_socket, kMessageSize, kMessages, kUdpWriteDelayMs); |
439 tester.Start(); | 438 tester.Start(); |
440 message_loop_.Run(); | 439 message_loop_.Run(); |
441 tester.CheckResults(); | 440 tester.CheckResults(); |
442 } | 441 } |
443 | 442 |
444 } // namespace protocol | 443 } // namespace protocol |
445 } // namespace remoting | 444 } // namespace remoting |
OLD | NEW |