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 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
| 1341 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
| 1342 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1339 LocalP2PTest(); | 1343 LocalP2PTest(); |
1340 | 1344 |
1341 EXPECT_EQ_WAIT( | 1345 EXPECT_EQ_WAIT( |
1342 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), | 1346 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
1343 initializing_client()->GetDtlsCipherStats(), | 1347 initializing_client()->GetDtlsCipherStats(), |
1344 kMaxWaitForStatsMs); | 1348 kMaxWaitForStatsMs); |
| 1349 EXPECT_EQ( |
| 1350 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
| 1351 init_observer->GetStringHistogramSample(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->GetStringHistogramSample(webrtc::kAudioSrtpCipher)); |
1350 } | 1360 } |
1351 | 1361 |
1352 // Test that DTLS 1.2 is used if both ends support it. | 1362 // Test that DTLS 1.2 is used if both ends support it. |
1353 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Both) { | 1363 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Both) { |
1354 PeerConnectionFactory::Options init_options; | 1364 PeerConnectionFactory::Options init_options; |
1355 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1365 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1356 PeerConnectionFactory::Options recv_options; | 1366 PeerConnectionFactory::Options recv_options; |
1357 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1367 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1358 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1368 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); |
| 1369 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
| 1370 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
| 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->GetStringHistogramSample(webrtc::kAudioSslCipher)); |
1365 | 1381 |
1366 EXPECT_EQ_WAIT( | 1382 EXPECT_EQ_WAIT( |
1367 kDefaultSrtpCipher, | 1383 kDefaultSrtpCipher, |
1368 initializing_client()->GetSrtpCipherStats(), | 1384 initializing_client()->GetSrtpCipherStats(), |
1369 kMaxWaitForStatsMs); | 1385 kMaxWaitForStatsMs); |
| 1386 EXPECT_EQ( |
| 1387 kDefaultSrtpCipher, |
| 1388 init_observer->GetStringHistogramSample(webrtc::kAudioSrtpCipher)); |
1370 } | 1389 } |
1371 | 1390 |
1372 // Test that DTLS 1.0 is used if the initator supports DTLS 1.2 and the | 1391 // Test that DTLS 1.0 is used if the initator supports DTLS 1.2 and the |
1373 // received supports 1.0. | 1392 // received supports 1.0. |
1374 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Init) { | 1393 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Init) { |
1375 PeerConnectionFactory::Options init_options; | 1394 PeerConnectionFactory::Options init_options; |
1376 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1395 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1377 PeerConnectionFactory::Options recv_options; | 1396 PeerConnectionFactory::Options recv_options; |
1378 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1397 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1379 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1398 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); |
| 1399 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
| 1400 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
| 1401 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1380 LocalP2PTest(); | 1402 LocalP2PTest(); |
1381 | 1403 |
1382 EXPECT_EQ_WAIT( | 1404 EXPECT_EQ_WAIT( |
1383 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), | 1405 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
1384 initializing_client()->GetDtlsCipherStats(), | 1406 initializing_client()->GetDtlsCipherStats(), |
1385 kMaxWaitForStatsMs); | 1407 kMaxWaitForStatsMs); |
| 1408 EXPECT_EQ( |
| 1409 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
| 1410 init_observer->GetStringHistogramSample(webrtc::kAudioSslCipher)); |
1386 | 1411 |
1387 EXPECT_EQ_WAIT( | 1412 EXPECT_EQ_WAIT( |
1388 kDefaultSrtpCipher, | 1413 kDefaultSrtpCipher, |
1389 initializing_client()->GetSrtpCipherStats(), | 1414 initializing_client()->GetSrtpCipherStats(), |
1390 kMaxWaitForStatsMs); | 1415 kMaxWaitForStatsMs); |
| 1416 EXPECT_EQ( |
| 1417 kDefaultSrtpCipher, |
| 1418 init_observer->GetStringHistogramSample(webrtc::kAudioSrtpCipher)); |
1391 } | 1419 } |
1392 | 1420 |
1393 // Test that DTLS 1.0 is used if the initator supports DTLS 1.0 and the | 1421 // Test that DTLS 1.0 is used if the initator supports DTLS 1.0 and the |
1394 // received supports 1.2. | 1422 // received supports 1.2. |
1395 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Recv) { | 1423 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Recv) { |
1396 PeerConnectionFactory::Options init_options; | 1424 PeerConnectionFactory::Options init_options; |
1397 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1425 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1398 PeerConnectionFactory::Options recv_options; | 1426 PeerConnectionFactory::Options recv_options; |
1399 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1427 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1400 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); | 1428 ASSERT_TRUE(CreateTestClients(NULL, &init_options, NULL, &recv_options)); |
| 1429 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
| 1430 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
| 1431 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1401 LocalP2PTest(); | 1432 LocalP2PTest(); |
1402 | 1433 |
1403 EXPECT_EQ_WAIT( | 1434 EXPECT_EQ_WAIT( |
1404 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), | 1435 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
1405 initializing_client()->GetDtlsCipherStats(), | 1436 initializing_client()->GetDtlsCipherStats(), |
1406 kMaxWaitForStatsMs); | 1437 kMaxWaitForStatsMs); |
| 1438 EXPECT_EQ( |
| 1439 rtc::SSLStreamAdapter::GetDefaultSslCipher(rtc::SSL_PROTOCOL_DTLS_10), |
| 1440 init_observer->GetStringHistogramSample(webrtc::kAudioSslCipher)); |
1407 | 1441 |
1408 EXPECT_EQ_WAIT( | 1442 EXPECT_EQ_WAIT( |
1409 kDefaultSrtpCipher, | 1443 kDefaultSrtpCipher, |
1410 initializing_client()->GetSrtpCipherStats(), | 1444 initializing_client()->GetSrtpCipherStats(), |
1411 kMaxWaitForStatsMs); | 1445 kMaxWaitForStatsMs); |
| 1446 EXPECT_EQ( |
| 1447 kDefaultSrtpCipher, |
| 1448 init_observer->GetStringHistogramSample(webrtc::kAudioSrtpCipher)); |
1412 } | 1449 } |
1413 | 1450 |
1414 // This test sets up a call between two parties with audio, video and data. | 1451 // This test sets up a call between two parties with audio, video and data. |
1415 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) { | 1452 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) { |
1416 FakeConstraints setup_constraints; | 1453 FakeConstraints setup_constraints; |
1417 setup_constraints.SetAllowRtpDataChannels(); | 1454 setup_constraints.SetAllowRtpDataChannels(); |
1418 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1455 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1419 initializing_client()->CreateDataChannel(); | 1456 initializing_client()->CreateDataChannel(); |
1420 LocalP2PTest(); | 1457 LocalP2PTest(); |
1421 ASSERT_TRUE(initializing_client()->data_channel() != NULL); | 1458 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. | 1620 // TODO(holmer): Disabled due to sometimes crashing on buildbots. |
1584 // See issue webrtc/2378. | 1621 // See issue webrtc/2378. |
1585 TEST_F(JsepPeerConnectionP2PTestClient, | 1622 TEST_F(JsepPeerConnectionP2PTestClient, |
1586 DISABLED_LocalP2PTestWithVideoDecoderFactory) { | 1623 DISABLED_LocalP2PTestWithVideoDecoderFactory) { |
1587 ASSERT_TRUE(CreateTestClients()); | 1624 ASSERT_TRUE(CreateTestClients()); |
1588 EnableVideoDecoderFactory(); | 1625 EnableVideoDecoderFactory(); |
1589 LocalP2PTest(); | 1626 LocalP2PTest(); |
1590 } | 1627 } |
1591 | 1628 |
1592 #endif // if !defined(THREAD_SANITIZER) | 1629 #endif // if !defined(THREAD_SANITIZER) |
OLD | NEW |