OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 | 27 |
28 #include <stdio.h> | 28 #include <stdio.h> |
29 | 29 |
30 #include <algorithm> | 30 #include <algorithm> |
31 #include <list> | 31 #include <list> |
32 #include <map> | 32 #include <map> |
33 #include <vector> | 33 #include <vector> |
34 | 34 |
35 #include "talk/app/webrtc/dtmfsender.h" | 35 #include "talk/app/webrtc/dtmfsender.h" |
| 36 #include "talk/app/webrtc/fakemetricsobserver.h" |
36 #include "talk/app/webrtc/fakeportallocatorfactory.h" | 37 #include "talk/app/webrtc/fakeportallocatorfactory.h" |
37 #include "talk/app/webrtc/localaudiosource.h" | 38 #include "talk/app/webrtc/localaudiosource.h" |
38 #include "talk/app/webrtc/mediastreaminterface.h" | 39 #include "talk/app/webrtc/mediastreaminterface.h" |
39 #include "talk/app/webrtc/peerconnectionfactory.h" | 40 #include "talk/app/webrtc/peerconnectionfactory.h" |
40 #include "talk/app/webrtc/peerconnectioninterface.h" | 41 #include "talk/app/webrtc/peerconnectioninterface.h" |
41 #include "talk/app/webrtc/test/fakeaudiocapturemodule.h" | 42 #include "talk/app/webrtc/test/fakeaudiocapturemodule.h" |
42 #include "talk/app/webrtc/test/fakeconstraints.h" | 43 #include "talk/app/webrtc/test/fakeconstraints.h" |
43 #include "talk/app/webrtc/test/fakedtlsidentityservice.h" | 44 #include "talk/app/webrtc/test/fakedtlsidentityservice.h" |
44 #include "talk/app/webrtc/test/fakeperiodicvideocapturer.h" | 45 #include "talk/app/webrtc/test/fakeperiodicvideocapturer.h" |
45 #include "talk/app/webrtc/test/fakevideotrackrenderer.h" | 46 #include "talk/app/webrtc/test/fakevideotrackrenderer.h" |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 kMaxWaitForStatsMs); | 1330 kMaxWaitForStatsMs); |
1330 } | 1331 } |
1331 | 1332 |
1332 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. | 1333 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. |
1333 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12None) { | 1334 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12None) { |
1334 PeerConnectionFactory::Options init_options; | 1335 PeerConnectionFactory::Options init_options; |
1335 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1336 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1336 PeerConnectionFactory::Options recv_options; | 1337 PeerConnectionFactory::Options recv_options; |
1337 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1338 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1338 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1339 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); |
| 1340 webrtc::FakeMetricsObserver init_observer; |
| 1341 initializing_client()->pc()->RegisterUMAObserver(&init_observer); |
1339 LocalP2PTest(); | 1342 LocalP2PTest(); |
1340 | 1343 |
1341 EXPECT_EQ_WAIT( | 1344 EXPECT_EQ_WAIT( |
1342 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), | 1345 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
1343 initializing_client()->GetDtlsCipherStats(), | 1346 initializing_client()->GetDtlsCipherStats(), |
1344 kMaxWaitForStatsMs); | 1347 kMaxWaitForStatsMs); |
| 1348 EXPECT_EQ( |
| 1349 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
| 1350 init_observer.peer_connection_metrics_name_string_ |
| 1351 [webrtc::kAudioSslCipher]); |
1345 | 1352 |
1346 EXPECT_EQ_WAIT( | 1353 EXPECT_EQ_WAIT( |
1347 kDefaultSrtpCipher, | 1354 kDefaultSrtpCipher, |
1348 initializing_client()->GetSrtpCipherStats(), | 1355 initializing_client()->GetSrtpCipherStats(), |
1349 kMaxWaitForStatsMs); | 1356 kMaxWaitForStatsMs); |
| 1357 EXPECT_EQ( |
| 1358 kDefaultSrtpCipher, |
| 1359 init_observer.peer_connection_metrics_name_string_ |
| 1360 [webrtc::kAudioSrtpCipher]); |
1350 } | 1361 } |
1351 | 1362 |
1352 // Test that DTLS 1.2 is used if both ends support it. | 1363 // Test that DTLS 1.2 is used if both ends support it. |
1353 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Both) { | 1364 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Both) { |
1354 PeerConnectionFactory::Options init_options; | 1365 PeerConnectionFactory::Options init_options; |
1355 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1366 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1356 PeerConnectionFactory::Options recv_options; | 1367 PeerConnectionFactory::Options recv_options; |
1357 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1368 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1358 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1369 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); |
| 1370 webrtc::FakeMetricsObserver init_observer; |
| 1371 initializing_client()->pc()->RegisterUMAObserver(&init_observer); |
1359 LocalP2PTest(); | 1372 LocalP2PTest(); |
1360 | 1373 |
1361 EXPECT_EQ_WAIT( | 1374 EXPECT_EQ_WAIT( |
1362 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_12), | 1375 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_12), |
1363 initializing_client()->GetDtlsCipherStats(), | 1376 initializing_client()->GetDtlsCipherStats(), |
1364 kMaxWaitForStatsMs); | 1377 kMaxWaitForStatsMs); |
| 1378 EXPECT_EQ( |
| 1379 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_12), |
| 1380 init_observer.peer_connection_metrics_name_string_ |
| 1381 [webrtc::kAudioSslCipher]); |
1365 | 1382 |
1366 EXPECT_EQ_WAIT( | 1383 EXPECT_EQ_WAIT( |
1367 kDefaultSrtpCipher, | 1384 kDefaultSrtpCipher, |
1368 initializing_client()->GetSrtpCipherStats(), | 1385 initializing_client()->GetSrtpCipherStats(), |
1369 kMaxWaitForStatsMs); | 1386 kMaxWaitForStatsMs); |
| 1387 EXPECT_EQ( |
| 1388 kDefaultSrtpCipher, |
| 1389 init_observer.peer_connection_metrics_name_string_ |
| 1390 [webrtc::kAudioSrtpCipher]); |
1370 } | 1391 } |
1371 | 1392 |
1372 // Test that DTLS 1.0 is used if the initator supports DTLS 1.2 and the | 1393 // Test that DTLS 1.0 is used if the initator supports DTLS 1.2 and the |
1373 // received supports 1.0. | 1394 // received supports 1.0. |
1374 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Init) { | 1395 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Init) { |
1375 PeerConnectionFactory::Options init_options; | 1396 PeerConnectionFactory::Options init_options; |
1376 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1397 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1377 PeerConnectionFactory::Options recv_options; | 1398 PeerConnectionFactory::Options recv_options; |
1378 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1399 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1379 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1400 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); |
| 1401 webrtc::FakeMetricsObserver init_observer; |
| 1402 initializing_client()->pc()->RegisterUMAObserver(&init_observer); |
1380 LocalP2PTest(); | 1403 LocalP2PTest(); |
1381 | 1404 |
1382 EXPECT_EQ_WAIT( | 1405 EXPECT_EQ_WAIT( |
1383 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), | 1406 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
1384 initializing_client()->GetDtlsCipherStats(), | 1407 initializing_client()->GetDtlsCipherStats(), |
1385 kMaxWaitForStatsMs); | 1408 kMaxWaitForStatsMs); |
| 1409 EXPECT_EQ( |
| 1410 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
| 1411 init_observer.peer_connection_metrics_name_string_ |
| 1412 [webrtc::kAudioSslCipher]); |
1386 | 1413 |
1387 EXPECT_EQ_WAIT( | 1414 EXPECT_EQ_WAIT( |
1388 kDefaultSrtpCipher, | 1415 kDefaultSrtpCipher, |
1389 initializing_client()->GetSrtpCipherStats(), | 1416 initializing_client()->GetSrtpCipherStats(), |
1390 kMaxWaitForStatsMs); | 1417 kMaxWaitForStatsMs); |
| 1418 EXPECT_EQ( |
| 1419 kDefaultSrtpCipher, |
| 1420 init_observer.peer_connection_metrics_name_string_ |
| 1421 [webrtc::kAudioSrtpCipher]); |
1391 } | 1422 } |
1392 | 1423 |
1393 // Test that DTLS 1.0 is used if the initator supports DTLS 1.0 and the | 1424 // Test that DTLS 1.0 is used if the initator supports DTLS 1.0 and the |
1394 // received supports 1.2. | 1425 // received supports 1.2. |
1395 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Recv) { | 1426 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Recv) { |
1396 PeerConnectionFactory::Options init_options; | 1427 PeerConnectionFactory::Options init_options; |
1397 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1428 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1398 PeerConnectionFactory::Options recv_options; | 1429 PeerConnectionFactory::Options recv_options; |
1399 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1430 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1400 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1431 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); |
| 1432 webrtc::FakeMetricsObserver init_observer; |
| 1433 initializing_client()->pc()->RegisterUMAObserver(&init_observer); |
1401 LocalP2PTest(); | 1434 LocalP2PTest(); |
1402 | 1435 |
1403 EXPECT_EQ_WAIT( | 1436 EXPECT_EQ_WAIT( |
1404 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), | 1437 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
1405 initializing_client()->GetDtlsCipherStats(), | 1438 initializing_client()->GetDtlsCipherStats(), |
1406 kMaxWaitForStatsMs); | 1439 kMaxWaitForStatsMs); |
| 1440 EXPECT_EQ( |
| 1441 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
| 1442 init_observer.peer_connection_metrics_name_string_ |
| 1443 [webrtc::kAudioSslCipher]); |
1407 | 1444 |
1408 EXPECT_EQ_WAIT( | 1445 EXPECT_EQ_WAIT( |
1409 kDefaultSrtpCipher, | 1446 kDefaultSrtpCipher, |
1410 initializing_client()->GetSrtpCipherStats(), | 1447 initializing_client()->GetSrtpCipherStats(), |
1411 kMaxWaitForStatsMs); | 1448 kMaxWaitForStatsMs); |
| 1449 EXPECT_EQ( |
| 1450 kDefaultSrtpCipher, |
| 1451 init_observer.peer_connection_metrics_name_string_ |
| 1452 [webrtc::kAudioSrtpCipher]); |
1412 } | 1453 } |
1413 | 1454 |
1414 // This test sets up a call between two parties with audio, video and data. | 1455 // This test sets up a call between two parties with audio, video and data. |
1415 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) { | 1456 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) { |
1416 FakeConstraints setup_constraints; | 1457 FakeConstraints setup_constraints; |
1417 setup_constraints.SetAllowRtpDataChannels(); | 1458 setup_constraints.SetAllowRtpDataChannels(); |
1418 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1459 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1419 initializing_client()->CreateDataChannel(); | 1460 initializing_client()->CreateDataChannel(); |
1420 LocalP2PTest(); | 1461 LocalP2PTest(); |
1421 ASSERT_TRUE(initializing_client()->data_channel() != NULL); | 1462 ASSERT_TRUE(initializing_client()->data_channel() != NULL); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 // TODO(holmer): Disabled due to sometimes crashing on buildbots. | 1624 // TODO(holmer): Disabled due to sometimes crashing on buildbots. |
1584 // See issue webrtc/2378. | 1625 // See issue webrtc/2378. |
1585 TEST_F(JsepPeerConnectionP2PTestClient, | 1626 TEST_F(JsepPeerConnectionP2PTestClient, |
1586 DISABLED_LocalP2PTestWithVideoDecoderFactory) { | 1627 DISABLED_LocalP2PTestWithVideoDecoderFactory) { |
1587 ASSERT_TRUE(CreateTestClients()); | 1628 ASSERT_TRUE(CreateTestClients()); |
1588 EnableVideoDecoderFactory(); | 1629 EnableVideoDecoderFactory(); |
1589 LocalP2PTest(); | 1630 LocalP2PTest(); |
1590 } | 1631 } |
1591 | 1632 |
1592 #endif // if !defined(THREAD_SANITIZER) | 1633 #endif // if !defined(THREAD_SANITIZER) |
OLD | NEW |