Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: talk/app/webrtc/statscollector_unittest.cc

Issue 1416673006: Convert internal representation of Srtp cryptos from string to int. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: change srtp crypto name conversion Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/statscollector.cc ('k') | talk/app/webrtc/webrtcsession.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 const std::vector<std::string>& local_ders, 676 const std::vector<std::string>& local_ders,
677 const rtc::FakeSSLCertificate& remote_cert, 677 const rtc::FakeSSLCertificate& remote_cert,
678 const std::vector<std::string>& remote_ders) { 678 const std::vector<std::string>& remote_ders) {
679 StatsCollectorForTest stats(&pc_); 679 StatsCollectorForTest stats(&pc_);
680 680
681 StatsReports reports; // returned values. 681 StatsReports reports; // returned values.
682 682
683 // Fake stats to process. 683 // Fake stats to process.
684 cricket::TransportChannelStats channel_stats; 684 cricket::TransportChannelStats channel_stats;
685 channel_stats.component = 1; 685 channel_stats.component = 1;
686 channel_stats.srtp_cipher = "the-srtp-cipher"; 686 channel_stats.srtp_crypto_suite = rtc::SRTP_AES128_CM_SHA1_80;
687 channel_stats.ssl_cipher = TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA; 687 channel_stats.ssl_cipher_suite = TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA;
688 688
689 cricket::TransportStats transport_stats; 689 cricket::TransportStats transport_stats;
690 transport_stats.transport_name = "audio"; 690 transport_stats.transport_name = "audio";
691 transport_stats.channel_stats.push_back(channel_stats); 691 transport_stats.channel_stats.push_back(channel_stats);
692 692
693 SessionStats session_stats; 693 SessionStats session_stats;
694 session_stats.transport_stats[transport_stats.transport_name] = 694 session_stats.transport_stats[transport_stats.transport_name] =
695 transport_stats; 695 transport_stats;
696 696
697 // Fake certificate to report 697 // Fake certificate to report
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 StatsReport::kStatsValueNameRemoteCertificateId); 740 StatsReport::kStatsValueNameRemoteCertificateId);
741 if (remote_ders.size() > 0) { 741 if (remote_ders.size() > 0) {
742 EXPECT_NE(kNotFound, remote_certificate_id); 742 EXPECT_NE(kNotFound, remote_certificate_id);
743 StatsReport::Id id(IdFromCertIdString(remote_certificate_id)); 743 StatsReport::Id id(IdFromCertIdString(remote_certificate_id));
744 CheckCertChainReports(reports, remote_ders, id); 744 CheckCertChainReports(reports, remote_ders, id);
745 } else { 745 } else {
746 EXPECT_EQ(kNotFound, remote_certificate_id); 746 EXPECT_EQ(kNotFound, remote_certificate_id);
747 } 747 }
748 748
749 // Check negotiated ciphers. 749 // Check negotiated ciphers.
750 std::string dtls_cipher = ExtractStatsValue( 750 std::string dtls_cipher_suite =
751 StatsReport::kStatsReportTypeComponent, 751 ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports,
752 reports, 752 StatsReport::kStatsValueNameDtlsCipher);
753 StatsReport::kStatsValueNameDtlsCipher); 753 EXPECT_EQ(rtc::SSLStreamAdapter::SslCipherSuiteToName(
754 EXPECT_EQ(rtc::SSLStreamAdapter::GetSslCipherSuiteName(
755 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA), 754 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA),
756 dtls_cipher); 755 dtls_cipher_suite);
757 std::string srtp_cipher = ExtractStatsValue( 756 std::string srtp_crypto_suite =
758 StatsReport::kStatsReportTypeComponent, 757 ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports,
759 reports, 758 StatsReport::kStatsValueNameSrtpCipher);
760 StatsReport::kStatsValueNameSrtpCipher); 759 EXPECT_EQ(rtc::SrtpCryptoSuiteToName(rtc::SRTP_AES128_CM_SHA1_80),
761 EXPECT_EQ("the-srtp-cipher", srtp_cipher); 760 srtp_crypto_suite);
762 } 761 }
763 762
764 cricket::FakeMediaEngine* media_engine_; 763 cricket::FakeMediaEngine* media_engine_;
765 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; 764 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_;
766 rtc::scoped_ptr<webrtc::MediaControllerInterface> media_controller_; 765 rtc::scoped_ptr<webrtc::MediaControllerInterface> media_controller_;
767 MockWebRtcSession session_; 766 MockWebRtcSession session_;
768 MockPeerConnection pc_; 767 MockPeerConnection pc_;
769 FakeDataChannelProvider data_channel_provider_; 768 FakeDataChannelProvider data_channel_provider_;
770 SessionStats session_stats_; 769 SessionStats session_stats_;
771 rtc::scoped_refptr<webrtc::MediaStream> stream_; 770 rtc::scoped_refptr<webrtc::MediaStream> stream_;
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 ASSERT_EQ(kNotFound, local_certificate_id); 1399 ASSERT_EQ(kNotFound, local_certificate_id);
1401 1400
1402 // Check that the remote certificate is absent. 1401 // Check that the remote certificate is absent.
1403 std::string remote_certificate_id = ExtractStatsValue( 1402 std::string remote_certificate_id = ExtractStatsValue(
1404 StatsReport::kStatsReportTypeComponent, 1403 StatsReport::kStatsReportTypeComponent,
1405 reports, 1404 reports,
1406 StatsReport::kStatsValueNameRemoteCertificateId); 1405 StatsReport::kStatsValueNameRemoteCertificateId);
1407 ASSERT_EQ(kNotFound, remote_certificate_id); 1406 ASSERT_EQ(kNotFound, remote_certificate_id);
1408 1407
1409 // Check that the negotiated ciphers are absent. 1408 // Check that the negotiated ciphers are absent.
1410 std::string dtls_cipher = ExtractStatsValue( 1409 std::string dtls_cipher_suite =
1411 StatsReport::kStatsReportTypeComponent, 1410 ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports,
1412 reports, 1411 StatsReport::kStatsValueNameDtlsCipher);
1413 StatsReport::kStatsValueNameDtlsCipher); 1412 ASSERT_EQ(kNotFound, dtls_cipher_suite);
1414 ASSERT_EQ(kNotFound, dtls_cipher); 1413 std::string srtp_crypto_suite =
1415 std::string srtp_cipher = ExtractStatsValue( 1414 ExtractStatsValue(StatsReport::kStatsReportTypeComponent, reports,
1416 StatsReport::kStatsReportTypeComponent, 1415 StatsReport::kStatsValueNameSrtpCipher);
1417 reports, 1416 ASSERT_EQ(kNotFound, srtp_crypto_suite);
1418 StatsReport::kStatsValueNameSrtpCipher);
1419 ASSERT_EQ(kNotFound, srtp_cipher);
1420 } 1417 }
1421 1418
1422 // This test verifies that the stats are generated correctly when the transport 1419 // This test verifies that the stats are generated correctly when the transport
1423 // does not have any certificates. 1420 // does not have any certificates.
1424 TEST_F(StatsCollectorTest, NoCertificates) { 1421 TEST_F(StatsCollectorTest, NoCertificates) {
1425 StatsCollectorForTest stats(&pc_); 1422 StatsCollectorForTest stats(&pc_);
1426 1423
1427 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 1424 EXPECT_CALL(session_, GetLocalCertificate(_, _))
1428 .WillRepeatedly(Return(false)); 1425 .WillRepeatedly(Return(false));
1429 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) 1426 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 cricket::VoiceSenderInfo new_voice_sender_info; 1741 cricket::VoiceSenderInfo new_voice_sender_info;
1745 InitVoiceSenderInfo(&new_voice_sender_info); 1742 InitVoiceSenderInfo(&new_voice_sender_info);
1746 cricket::VoiceMediaInfo new_stats_read; 1743 cricket::VoiceMediaInfo new_stats_read;
1747 reports.clear(); 1744 reports.clear();
1748 SetupAndVerifyAudioTrackStats( 1745 SetupAndVerifyAudioTrackStats(
1749 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, 1746 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName,
1750 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); 1747 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports);
1751 } 1748 }
1752 1749
1753 } // namespace webrtc 1750 } // namespace webrtc
OLDNEW
« no previous file with comments | « talk/app/webrtc/statscollector.cc ('k') | talk/app/webrtc/webrtcsession.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698