OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop_proxy.h" | 6 #include "base/message_loop_proxy.h" |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 | 178 |
179 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) | 179 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) |
180 .WillOnce(DoAll( | 180 .WillOnce(DoAll( |
181 WithArg<0>(Invoke( | 181 WithArg<0>(Invoke( |
182 this, &JingleSessionTest::SetHostSession)), | 182 this, &JingleSessionTest::SetHostSession)), |
183 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); | 183 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); |
184 | 184 |
185 { | 185 { |
186 InSequence dummy; | 186 InSequence dummy; |
187 | 187 |
188 EXPECT_CALL(host_connection_callback_, | |
189 OnStateChange(Session::CONNECTED)) | |
190 .Times(AtMost(1)); | |
188 if (expect_fail) { | 191 if (expect_fail) { |
189 EXPECT_CALL(host_connection_callback_, | 192 EXPECT_CALL(host_connection_callback_, |
190 OnStateChange(Session::FAILED)) | 193 OnStateChange(Session::FAILED)) |
191 .Times(1) | 194 .Times(1) |
192 .WillOnce(QuitThreadOnCounter(¬_connected_peers)); | 195 .WillOnce(QuitThreadOnCounter(¬_connected_peers)); |
193 } else { | 196 } else { |
194 EXPECT_CALL(host_connection_callback_, | 197 EXPECT_CALL(host_connection_callback_, |
195 OnStateChange(Session::CONNECTED)) | |
196 .Times(1); | |
197 EXPECT_CALL(host_connection_callback_, | |
198 OnStateChange(Session::AUTHENTICATED)) | 198 OnStateChange(Session::AUTHENTICATED)) |
199 .Times(1) | 199 .Times(1) |
200 .WillOnce(QuitThreadOnCounter(¬_connected_peers)); | 200 .WillOnce(QuitThreadOnCounter(¬_connected_peers)); |
201 // Expect that the connection will be closed eventually. | 201 // Expect that the connection will be closed eventually. |
202 EXPECT_CALL(host_connection_callback_, | 202 EXPECT_CALL(host_connection_callback_, |
203 OnStateChange(Session::CLOSED)) | 203 OnStateChange(Session::CLOSED)) |
204 .Times(AtMost(1)); | 204 .Times(AtMost(1)); |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 { | 208 { |
209 InSequence dummy; | 209 InSequence dummy; |
210 | 210 |
211 EXPECT_CALL(client_connection_callback_, | 211 EXPECT_CALL(client_connection_callback_, |
212 OnStateChange(Session::CONNECTING)) | 212 OnStateChange(Session::CONNECTING)) |
213 .Times(1); | 213 .Times(1); |
214 EXPECT_CALL(client_connection_callback_, | |
215 OnStateChange(Session::CONNECTED)) | |
216 .Times(AtMost(1)); | |
214 if (!expect_fail) { | 217 if (!expect_fail) { |
215 EXPECT_CALL(client_connection_callback_, | 218 EXPECT_CALL(client_connection_callback_, |
216 OnStateChange(Session::CONNECTED)) | |
217 .Times(1); | |
218 EXPECT_CALL(client_connection_callback_, | |
219 OnStateChange(Session::AUTHENTICATED)) | 219 OnStateChange(Session::AUTHENTICATED)) |
220 .Times(1) | 220 .Times(1) |
221 .WillOnce(QuitThreadOnCounter(¬_connected_peers)); | 221 .WillOnce(QuitThreadOnCounter(¬_connected_peers)); |
222 } | 222 } |
223 // Expect that the connection will be closed eventually. | 223 // Expect that the connection will be closed eventually. |
224 EXPECT_CALL(client_connection_callback_, | 224 EXPECT_CALL(client_connection_callback_, |
225 OnStateChange(Session::CLOSED)) | 225 OnStateChange(Session::CLOSED)) |
226 .Times(AtMost(1)); | 226 .Times(AtMost(1)); |
227 } | 227 } |
228 | 228 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 | 343 |
344 ASSERT_TRUE(RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms())); | 344 ASSERT_TRUE(RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms())); |
345 } | 345 } |
346 | 346 |
347 // Verify that we can connect two endpoints. | 347 // Verify that we can connect two endpoints. |
348 TEST_F(JingleSessionTest, Connect) { | 348 TEST_F(JingleSessionTest, Connect) { |
349 CreateServerPair(FakeAuthenticator::ACCEPT, 1); | 349 CreateServerPair(FakeAuthenticator::ACCEPT, 1); |
350 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 1, false)); | 350 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 1, false)); |
351 } | 351 } |
352 | 352 |
353 // Verify that we can't connect two endpoints with mismatched secrets. | 353 // Verify that we can connect two endpoints with multi-step |
354 // authentication. | |
Wez
2011/12/03 00:21:05
nit: premature line-wrap?
Sergey Ulanov
2011/12/06 19:37:07
Done.
| |
355 TEST_F(JingleSessionTest, ConnectMultistep) { | |
356 CreateServerPair(FakeAuthenticator::ACCEPT, 3); | |
357 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 3, false)); | |
358 } | |
359 | |
360 // Verify that connection is terminted when auth fails. | |
354 TEST_F(JingleSessionTest, ConnectBadAuth) { | 361 TEST_F(JingleSessionTest, ConnectBadAuth) { |
355 CreateServerPair(FakeAuthenticator::REJECT, 1); | 362 CreateServerPair(FakeAuthenticator::REJECT, 1); |
356 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 1, true)); | 363 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 1, true)); |
357 } | 364 } |
358 | 365 |
366 // Verify that connection is terminted when multi-step auth fails. | |
Wez
2011/12/03 00:21:05
nit: terminated
Sergey Ulanov
2011/12/06 19:37:07
Done.
| |
367 TEST_F(JingleSessionTest, ConnectBadMultistepAuth) { | |
368 CreateServerPair(FakeAuthenticator::REJECT, 3); | |
369 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 3, true)); | |
370 } | |
371 | |
359 TEST_F(JingleSessionTest, ConnectBadChannelAuth) { | 372 TEST_F(JingleSessionTest, ConnectBadChannelAuth) { |
360 CreateServerPair(FakeAuthenticator::REJECT_CHANNEL, 1); | 373 CreateServerPair(FakeAuthenticator::REJECT_CHANNEL, 1); |
361 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 1, false)); | 374 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 1, false)); |
362 | 375 |
363 MockStreamChannelCallback client_callback; | 376 MockStreamChannelCallback client_callback; |
364 MockStreamChannelCallback host_callback; | 377 MockStreamChannelCallback host_callback; |
365 | 378 |
366 client_session_->CreateStreamChannel(kChannelName, base::Bind( | 379 client_session_->CreateStreamChannel(kChannelName, base::Bind( |
367 &MockStreamChannelCallback::OnDone, | 380 &MockStreamChannelCallback::OnDone, |
368 base::Unretained(&client_callback))); | 381 base::Unretained(&client_callback))); |
(...skipping 20 matching lines...) Expand all Loading... | |
389 | 402 |
390 ASSERT_TRUE(CreateChannel()); | 403 ASSERT_TRUE(CreateChannel()); |
391 | 404 |
392 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | 405 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
393 kMessageSize, kMessages); | 406 kMessageSize, kMessages); |
394 tester.Start(); | 407 tester.Start(); |
395 message_loop_.Run(); | 408 message_loop_.Run(); |
396 tester.CheckResults(); | 409 tester.CheckResults(); |
397 } | 410 } |
398 | 411 |
412 // Verify that we can connect channgels with multistep auth. | |
Wez
2011/12/03 00:21:05
nit: channels
Sergey Ulanov
2011/12/06 19:37:07
Done.
| |
413 TEST_F(JingleSessionTest, TestMultistepAuthTcpChannel) { | |
414 CreateServerPair(FakeAuthenticator::ACCEPT, 3); | |
415 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 3, false)); | |
416 | |
417 ASSERT_TRUE(CreateChannel()); | |
418 | |
419 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | |
420 kMessageSize, kMessages); | |
421 tester.Start(); | |
422 message_loop_.Run(); | |
423 tester.CheckResults(); | |
424 } | |
425 | |
399 // Verify that data can be transmitted over the video RTP channel. | 426 // Verify that data can be transmitted over the video RTP channel. |
400 TEST_F(JingleSessionTest, TestUdpChannel) { | 427 TEST_F(JingleSessionTest, TestUdpChannel) { |
401 CreateServerPair(FakeAuthenticator::ACCEPT, 1); | 428 CreateServerPair(FakeAuthenticator::ACCEPT, 1); |
402 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 1, false)); | 429 ASSERT_TRUE(InitiateConnection(FakeAuthenticator::ACCEPT, 1, false)); |
403 | 430 |
404 MockDatagramChannelCallback client_callback; | 431 MockDatagramChannelCallback client_callback; |
405 MockDatagramChannelCallback host_callback; | 432 MockDatagramChannelCallback host_callback; |
406 | 433 |
407 int counter = 2; | 434 int counter = 2; |
408 net::Socket* client_socket = NULL; | 435 net::Socket* client_socket = NULL; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 CreateServerPair(FakeAuthenticator::ACCEPT, 1); | 469 CreateServerPair(FakeAuthenticator::ACCEPT, 1); |
443 | 470 |
444 RunSpeedTest(512); | 471 RunSpeedTest(512); |
445 RunSpeedTest(1024); | 472 RunSpeedTest(1024); |
446 RunSpeedTest(51200); | 473 RunSpeedTest(51200); |
447 RunSpeedTest(512000); | 474 RunSpeedTest(512000); |
448 } | 475 } |
449 | 476 |
450 } // namespace protocol | 477 } // namespace protocol |
451 } // namespace remoting | 478 } // namespace remoting |
OLD | NEW |