| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); | 75 MOCK_METHOD0(voice_channel, cricket::VoiceChannel*()); |
| 76 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); | 76 MOCK_METHOD0(video_channel, cricket::VideoChannel*()); |
| 77 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming | 77 // Libjingle uses "local" for a outgoing track, and "remote" for a incoming |
| 78 // track. | 78 // track. |
| 79 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*)); | 79 MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*)); |
| 80 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*)); | 80 MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*)); |
| 81 MOCK_METHOD1(GetTransportStats, bool(SessionStats*)); | 81 MOCK_METHOD1(GetTransportStats, bool(SessionStats*)); |
| 82 MOCK_METHOD2(GetLocalCertificate, | 82 MOCK_METHOD2(GetLocalCertificate, |
| 83 bool(const std::string& transport_name, | 83 bool(const std::string& transport_name, |
| 84 rtc::scoped_refptr<rtc::RTCCertificate>* certificate)); | 84 rtc::scoped_refptr<rtc::RTCCertificate>* certificate)); |
| 85 MOCK_METHOD2(GetRemoteSSLCertificate, | 85 |
| 86 bool(const std::string& transport_name, | 86 // Workaround for gmock's inability to cope with move-only return values. |
| 87 rtc::SSLCertificate** cert)); | 87 rtc::scoped_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate( |
| 88 const std::string& transport_name) override { |
| 89 return rtc::scoped_ptr<rtc::SSLCertificate>( |
| 90 GetRemoteSSLCertificate_ReturnsRawPointer(transport_name)); |
| 91 } |
| 92 MOCK_METHOD1(GetRemoteSSLCertificate_ReturnsRawPointer, |
| 93 rtc::SSLCertificate*(const std::string& transport_name)); |
| 88 }; | 94 }; |
| 89 | 95 |
| 90 // The factory isn't really used; it just satisfies the base PeerConnection. | 96 // The factory isn't really used; it just satisfies the base PeerConnection. |
| 91 class FakePeerConnectionFactory | 97 class FakePeerConnectionFactory |
| 92 : public rtc::RefCountedObject<PeerConnectionFactory> {}; | 98 : public rtc::RefCountedObject<PeerConnectionFactory> {}; |
| 93 | 99 |
| 94 class MockPeerConnection | 100 class MockPeerConnection |
| 95 : public rtc::RefCountedObject<webrtc::PeerConnection> { | 101 : public rtc::RefCountedObject<webrtc::PeerConnection> { |
| 96 public: | 102 public: |
| 97 MockPeerConnection() | 103 MockPeerConnection() |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 EXPECT_EQ(audio_track->id(), track_id); | 661 EXPECT_EQ(audio_track->id(), track_id); |
| 656 ssrc_id = ExtractSsrcStatsValue(track_reports, | 662 ssrc_id = ExtractSsrcStatsValue(track_reports, |
| 657 StatsReport::kStatsValueNameSsrc); | 663 StatsReport::kStatsValueNameSsrc); |
| 658 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id); | 664 EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id); |
| 659 if (voice_sender_info) | 665 if (voice_sender_info) |
| 660 VerifyVoiceSenderInfoReport(track_report, *voice_sender_info); | 666 VerifyVoiceSenderInfoReport(track_report, *voice_sender_info); |
| 661 if (voice_receiver_info) | 667 if (voice_receiver_info) |
| 662 VerifyVoiceReceiverInfoReport(track_report, *voice_receiver_info); | 668 VerifyVoiceReceiverInfoReport(track_report, *voice_receiver_info); |
| 663 } | 669 } |
| 664 | 670 |
| 665 void TestCertificateReports(const rtc::FakeSSLCertificate& local_cert, | 671 void TestCertificateReports( |
| 666 const std::vector<std::string>& local_ders, | 672 const rtc::FakeSSLCertificate& local_cert, |
| 667 const rtc::FakeSSLCertificate& remote_cert, | 673 const std::vector<std::string>& local_ders, |
| 668 const std::vector<std::string>& remote_ders) { | 674 rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert, |
| 675 const std::vector<std::string>& remote_ders) { |
| 669 StatsCollectorForTest stats(&pc_); | 676 StatsCollectorForTest stats(&pc_); |
| 670 | 677 |
| 671 StatsReports reports; // returned values. | 678 StatsReports reports; // returned values. |
| 672 | 679 |
| 673 // Fake stats to process. | 680 // Fake stats to process. |
| 674 cricket::TransportChannelStats channel_stats; | 681 cricket::TransportChannelStats channel_stats; |
| 675 channel_stats.component = 1; | 682 channel_stats.component = 1; |
| 676 channel_stats.srtp_crypto_suite = rtc::SRTP_AES128_CM_SHA1_80; | 683 channel_stats.srtp_crypto_suite = rtc::SRTP_AES128_CM_SHA1_80; |
| 677 channel_stats.ssl_cipher_suite = TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA; | 684 channel_stats.ssl_cipher_suite = TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA; |
| 678 | 685 |
| 679 cricket::TransportStats transport_stats; | 686 cricket::TransportStats transport_stats; |
| 680 transport_stats.transport_name = "audio"; | 687 transport_stats.transport_name = "audio"; |
| 681 transport_stats.channel_stats.push_back(channel_stats); | 688 transport_stats.channel_stats.push_back(channel_stats); |
| 682 | 689 |
| 683 SessionStats session_stats; | 690 SessionStats session_stats; |
| 684 session_stats.transport_stats[transport_stats.transport_name] = | 691 session_stats.transport_stats[transport_stats.transport_name] = |
| 685 transport_stats; | 692 transport_stats; |
| 686 | 693 |
| 687 // Fake certificate to report | 694 // Fake certificate to report |
| 688 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate( | 695 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate( |
| 689 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::FakeSSLIdentity>( | 696 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::FakeSSLIdentity>( |
| 690 new rtc::FakeSSLIdentity(local_cert)))); | 697 new rtc::FakeSSLIdentity(local_cert)))); |
| 691 | 698 |
| 692 // Configure MockWebRtcSession | 699 // Configure MockWebRtcSession |
| 693 EXPECT_CALL(session_, | 700 EXPECT_CALL(session_, |
| 694 GetLocalCertificate(transport_stats.transport_name, _)) | 701 GetLocalCertificate(transport_stats.transport_name, _)) |
| 695 .WillOnce(DoAll(SetArgPointee<1>(local_certificate), Return(true))); | 702 .WillOnce(DoAll(SetArgPointee<1>(local_certificate), Return(true))); |
| 696 EXPECT_CALL(session_, | 703 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer( |
| 697 GetRemoteSSLCertificate(transport_stats.transport_name, _)) | 704 transport_stats.transport_name)) |
| 698 .WillOnce( | 705 .WillOnce(Return(remote_cert.release())); |
| 699 DoAll(SetArgPointee<1>(remote_cert.GetReference()), Return(true))); | |
| 700 EXPECT_CALL(session_, GetTransportStats(_)) | 706 EXPECT_CALL(session_, GetTransportStats(_)) |
| 701 .WillOnce(DoAll(SetArgPointee<0>(session_stats), | 707 .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
| 702 Return(true))); | 708 Return(true))); |
| 703 | 709 |
| 704 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); | 710 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
| 705 | 711 |
| 706 stats.GetStats(NULL, &reports); | 712 stats.GetStats(NULL, &reports); |
| 707 | 713 |
| 708 const StatsReport* channel_report = FindNthReportByType( | 714 const StatsReport* channel_report = FindNthReportByType( |
| 709 reports, StatsReport::kStatsReportTypeComponent, 1); | 715 reports, StatsReport::kStatsReportTypeComponent, 1); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 reports, | 805 reports, |
| 800 StatsReport::kStatsValueNameProtocol)); | 806 StatsReport::kStatsValueNameProtocol)); |
| 801 } | 807 } |
| 802 | 808 |
| 803 // This test verifies that 64-bit counters are passed successfully. | 809 // This test verifies that 64-bit counters are passed successfully. |
| 804 TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { | 810 TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { |
| 805 StatsCollectorForTest stats(&pc_); | 811 StatsCollectorForTest stats(&pc_); |
| 806 | 812 |
| 807 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 813 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 808 .WillRepeatedly(Return(false)); | 814 .WillRepeatedly(Return(false)); |
| 809 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 815 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 810 .WillRepeatedly(Return(false)); | 816 .WillRepeatedly(Return(nullptr)); |
| 811 | 817 |
| 812 const char kVideoChannelName[] = "video"; | 818 const char kVideoChannelName[] = "video"; |
| 813 | 819 |
| 814 InitSessionStats(kVideoChannelName); | 820 InitSessionStats(kVideoChannelName); |
| 815 EXPECT_CALL(session_, GetTransportStats(_)) | 821 EXPECT_CALL(session_, GetTransportStats(_)) |
| 816 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 822 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 817 Return(true))); | 823 Return(true))); |
| 818 | 824 |
| 819 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 825 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 820 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 826 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 845 StatsReport::kStatsValueNameBytesSent); | 851 StatsReport::kStatsValueNameBytesSent); |
| 846 EXPECT_EQ(kBytesSentString, result); | 852 EXPECT_EQ(kBytesSentString, result); |
| 847 } | 853 } |
| 848 | 854 |
| 849 // Test that BWE information is reported via stats. | 855 // Test that BWE information is reported via stats. |
| 850 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { | 856 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { |
| 851 StatsCollectorForTest stats(&pc_); | 857 StatsCollectorForTest stats(&pc_); |
| 852 | 858 |
| 853 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 859 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 854 .WillRepeatedly(Return(false)); | 860 .WillRepeatedly(Return(false)); |
| 855 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 861 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 856 .WillRepeatedly(Return(false)); | 862 .WillRepeatedly(Return(nullptr)); |
| 857 | 863 |
| 858 const char kVideoChannelName[] = "video"; | 864 const char kVideoChannelName[] = "video"; |
| 859 | 865 |
| 860 InitSessionStats(kVideoChannelName); | 866 InitSessionStats(kVideoChannelName); |
| 861 EXPECT_CALL(session_, GetTransportStats(_)) | 867 EXPECT_CALL(session_, GetTransportStats(_)) |
| 862 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 868 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 863 Return(true))); | 869 Return(true))); |
| 864 | 870 |
| 865 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 871 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 866 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 872 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 EXPECT_EQ(kLocalTrackId, trackValue); | 963 EXPECT_EQ(kLocalTrackId, trackValue); |
| 958 } | 964 } |
| 959 | 965 |
| 960 // This test verifies that the empty track report exists in the returned stats | 966 // This test verifies that the empty track report exists in the returned stats |
| 961 // when StatsCollector::UpdateStats is called with ssrc stats. | 967 // when StatsCollector::UpdateStats is called with ssrc stats. |
| 962 TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { | 968 TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { |
| 963 StatsCollectorForTest stats(&pc_); | 969 StatsCollectorForTest stats(&pc_); |
| 964 | 970 |
| 965 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 971 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 966 .WillRepeatedly(Return(false)); | 972 .WillRepeatedly(Return(false)); |
| 967 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 973 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 968 .WillRepeatedly(Return(false)); | 974 .WillRepeatedly(Return(nullptr)); |
| 969 | 975 |
| 970 const char kVideoChannelName[] = "video"; | 976 const char kVideoChannelName[] = "video"; |
| 971 InitSessionStats(kVideoChannelName); | 977 InitSessionStats(kVideoChannelName); |
| 972 EXPECT_CALL(session_, GetTransportStats(_)) | 978 EXPECT_CALL(session_, GetTransportStats(_)) |
| 973 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 979 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 974 Return(true))); | 980 Return(true))); |
| 975 | 981 |
| 976 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 982 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 977 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 983 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 978 nullptr, kVideoChannelName, false); | 984 nullptr, kVideoChannelName, false); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 EXPECT_EQ("video", media_type); | 1035 EXPECT_EQ("video", media_type); |
| 1030 } | 1036 } |
| 1031 | 1037 |
| 1032 // This test verifies that an SSRC object has the identifier of a Transport | 1038 // This test verifies that an SSRC object has the identifier of a Transport |
| 1033 // stats object, and that this transport stats object exists in stats. | 1039 // stats object, and that this transport stats object exists in stats. |
| 1034 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { | 1040 TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { |
| 1035 StatsCollectorForTest stats(&pc_); | 1041 StatsCollectorForTest stats(&pc_); |
| 1036 | 1042 |
| 1037 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1043 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1038 .WillRepeatedly(Return(false)); | 1044 .WillRepeatedly(Return(false)); |
| 1039 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1045 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1040 .WillRepeatedly(Return(false)); | 1046 .WillRepeatedly(Return(nullptr)); |
| 1041 | 1047 |
| 1042 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1048 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1043 // The transport_name known by the video channel. | 1049 // The transport_name known by the video channel. |
| 1044 const std::string kVcName("vcname"); | 1050 const std::string kVcName("vcname"); |
| 1045 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 1051 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 1046 nullptr, kVcName, false); | 1052 nullptr, kVcName, false); |
| 1047 AddOutgoingVideoTrackStats(); | 1053 AddOutgoingVideoTrackStats(); |
| 1048 stats.AddStream(stream_); | 1054 stats.AddStream(stream_); |
| 1049 | 1055 |
| 1050 // Constructs an ssrc stats update. | 1056 // Constructs an ssrc stats update. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 EXPECT_TRUE(remote_report == NULL); | 1119 EXPECT_TRUE(remote_report == NULL); |
| 1114 } | 1120 } |
| 1115 | 1121 |
| 1116 // This test verifies that a remote stats object will be created for | 1122 // This test verifies that a remote stats object will be created for |
| 1117 // an outgoing SSRC where stats are returned. | 1123 // an outgoing SSRC where stats are returned. |
| 1118 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { | 1124 TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
| 1119 StatsCollectorForTest stats(&pc_); | 1125 StatsCollectorForTest stats(&pc_); |
| 1120 | 1126 |
| 1121 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1127 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1122 .WillRepeatedly(Return(false)); | 1128 .WillRepeatedly(Return(false)); |
| 1123 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1129 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1124 .WillRepeatedly(Return(false)); | 1130 .WillRepeatedly(Return(nullptr)); |
| 1125 | 1131 |
| 1126 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1132 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1127 // The transport_name known by the video channel. | 1133 // The transport_name known by the video channel. |
| 1128 const std::string kVcName("vcname"); | 1134 const std::string kVcName("vcname"); |
| 1129 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 1135 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 1130 nullptr, kVcName, false); | 1136 nullptr, kVcName, false); |
| 1131 AddOutgoingVideoTrackStats(); | 1137 AddOutgoingVideoTrackStats(); |
| 1132 stats.AddStream(stream_); | 1138 stats.AddStream(stream_); |
| 1133 | 1139 |
| 1134 // Instruct the session to return stats containing the transport channel. | 1140 // Instruct the session to return stats containing the transport channel. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1164 EXPECT_EQ(12345.678, remote_report->timestamp()); | 1170 EXPECT_EQ(12345.678, remote_report->timestamp()); |
| 1165 } | 1171 } |
| 1166 | 1172 |
| 1167 // This test verifies that the empty track report exists in the returned stats | 1173 // This test verifies that the empty track report exists in the returned stats |
| 1168 // when StatsCollector::UpdateStats is called with ssrc stats. | 1174 // when StatsCollector::UpdateStats is called with ssrc stats. |
| 1169 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { | 1175 TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { |
| 1170 StatsCollectorForTest stats(&pc_); | 1176 StatsCollectorForTest stats(&pc_); |
| 1171 | 1177 |
| 1172 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1178 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1173 .WillRepeatedly(Return(false)); | 1179 .WillRepeatedly(Return(false)); |
| 1174 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1180 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1175 .WillRepeatedly(Return(false)); | 1181 .WillRepeatedly(Return(nullptr)); |
| 1176 | 1182 |
| 1177 const char kVideoChannelName[] = "video"; | 1183 const char kVideoChannelName[] = "video"; |
| 1178 InitSessionStats(kVideoChannelName); | 1184 InitSessionStats(kVideoChannelName); |
| 1179 EXPECT_CALL(session_, GetTransportStats(_)) | 1185 EXPECT_CALL(session_, GetTransportStats(_)) |
| 1180 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), | 1186 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
| 1181 Return(true))); | 1187 Return(true))); |
| 1182 | 1188 |
| 1183 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); | 1189 MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
| 1184 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, | 1190 cricket::VideoChannel video_channel(rtc::Thread::Current(), media_channel, |
| 1185 nullptr, kVideoChannelName, false); | 1191 nullptr, kVideoChannelName, false); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 local_ders[3] = "der"; | 1331 local_ders[3] = "der"; |
| 1326 local_ders[4] = "values"; | 1332 local_ders[4] = "values"; |
| 1327 rtc::FakeSSLCertificate local_cert(DersToPems(local_ders)); | 1333 rtc::FakeSSLCertificate local_cert(DersToPems(local_ders)); |
| 1328 | 1334 |
| 1329 // Build remote certificate chain | 1335 // Build remote certificate chain |
| 1330 std::vector<std::string> remote_ders(4); | 1336 std::vector<std::string> remote_ders(4); |
| 1331 remote_ders[0] = "A"; | 1337 remote_ders[0] = "A"; |
| 1332 remote_ders[1] = "non-"; | 1338 remote_ders[1] = "non-"; |
| 1333 remote_ders[2] = "intersecting"; | 1339 remote_ders[2] = "intersecting"; |
| 1334 remote_ders[3] = "set"; | 1340 remote_ders[3] = "set"; |
| 1335 rtc::FakeSSLCertificate remote_cert(DersToPems(remote_ders)); | 1341 rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert( |
| 1342 new rtc::FakeSSLCertificate(DersToPems(remote_ders))); |
| 1336 | 1343 |
| 1337 TestCertificateReports(local_cert, local_ders, remote_cert, remote_ders); | 1344 TestCertificateReports(local_cert, local_ders, std::move(remote_cert), |
| 1345 remote_ders); |
| 1338 } | 1346 } |
| 1339 | 1347 |
| 1340 // This test verifies that all certificates without chains are correctly | 1348 // This test verifies that all certificates without chains are correctly |
| 1341 // reported. | 1349 // reported. |
| 1342 TEST_F(StatsCollectorTest, ChainlessCertificateReportsCreated) { | 1350 TEST_F(StatsCollectorTest, ChainlessCertificateReportsCreated) { |
| 1343 // Build local certificate. | 1351 // Build local certificate. |
| 1344 std::string local_der = "This is the local der."; | 1352 std::string local_der = "This is the local der."; |
| 1345 rtc::FakeSSLCertificate local_cert(DerToPem(local_der)); | 1353 rtc::FakeSSLCertificate local_cert(DerToPem(local_der)); |
| 1346 | 1354 |
| 1347 // Build remote certificate. | 1355 // Build remote certificate. |
| 1348 std::string remote_der = "This is somebody else's der."; | 1356 std::string remote_der = "This is somebody else's der."; |
| 1349 rtc::FakeSSLCertificate remote_cert(DerToPem(remote_der)); | 1357 rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert( |
| 1358 new rtc::FakeSSLCertificate(DerToPem(remote_der))); |
| 1350 | 1359 |
| 1351 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), | 1360 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), |
| 1352 remote_cert, std::vector<std::string>(1, remote_der)); | 1361 std::move(remote_cert), |
| 1362 std::vector<std::string>(1, remote_der)); |
| 1353 } | 1363 } |
| 1354 | 1364 |
| 1355 // This test verifies that the stats are generated correctly when no | 1365 // This test verifies that the stats are generated correctly when no |
| 1356 // transport is present. | 1366 // transport is present. |
| 1357 TEST_F(StatsCollectorTest, NoTransport) { | 1367 TEST_F(StatsCollectorTest, NoTransport) { |
| 1358 StatsCollectorForTest stats(&pc_); | 1368 StatsCollectorForTest stats(&pc_); |
| 1359 | 1369 |
| 1360 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1370 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1361 .WillRepeatedly(Return(false)); | 1371 .WillRepeatedly(Return(false)); |
| 1362 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1372 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1363 .WillRepeatedly(Return(false)); | 1373 .WillRepeatedly(Return(nullptr)); |
| 1364 | 1374 |
| 1365 StatsReports reports; // returned values. | 1375 StatsReports reports; // returned values. |
| 1366 | 1376 |
| 1367 // Fake stats to process. | 1377 // Fake stats to process. |
| 1368 cricket::TransportChannelStats channel_stats; | 1378 cricket::TransportChannelStats channel_stats; |
| 1369 channel_stats.component = 1; | 1379 channel_stats.component = 1; |
| 1370 | 1380 |
| 1371 cricket::TransportStats transport_stats; | 1381 cricket::TransportStats transport_stats; |
| 1372 transport_stats.transport_name = "audio"; | 1382 transport_stats.transport_name = "audio"; |
| 1373 transport_stats.channel_stats.push_back(channel_stats); | 1383 transport_stats.channel_stats.push_back(channel_stats); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 ASSERT_EQ(kNotFound, srtp_crypto_suite); | 1419 ASSERT_EQ(kNotFound, srtp_crypto_suite); |
| 1410 } | 1420 } |
| 1411 | 1421 |
| 1412 // This test verifies that the stats are generated correctly when the transport | 1422 // This test verifies that the stats are generated correctly when the transport |
| 1413 // does not have any certificates. | 1423 // does not have any certificates. |
| 1414 TEST_F(StatsCollectorTest, NoCertificates) { | 1424 TEST_F(StatsCollectorTest, NoCertificates) { |
| 1415 StatsCollectorForTest stats(&pc_); | 1425 StatsCollectorForTest stats(&pc_); |
| 1416 | 1426 |
| 1417 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1427 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1418 .WillRepeatedly(Return(false)); | 1428 .WillRepeatedly(Return(false)); |
| 1419 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1429 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1420 .WillRepeatedly(Return(false)); | 1430 .WillRepeatedly(Return(nullptr)); |
| 1421 | 1431 |
| 1422 StatsReports reports; // returned values. | 1432 StatsReports reports; // returned values. |
| 1423 | 1433 |
| 1424 // Fake stats to process. | 1434 // Fake stats to process. |
| 1425 cricket::TransportChannelStats channel_stats; | 1435 cricket::TransportChannelStats channel_stats; |
| 1426 channel_stats.component = 1; | 1436 channel_stats.component = 1; |
| 1427 | 1437 |
| 1428 cricket::TransportStats transport_stats; | 1438 cricket::TransportStats transport_stats; |
| 1429 transport_stats.transport_name = "audio"; | 1439 transport_stats.transport_name = "audio"; |
| 1430 transport_stats.channel_stats.push_back(channel_stats); | 1440 transport_stats.channel_stats.push_back(channel_stats); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1461 | 1471 |
| 1462 // This test verifies that a remote certificate with an unsupported digest | 1472 // This test verifies that a remote certificate with an unsupported digest |
| 1463 // algorithm is correctly ignored. | 1473 // algorithm is correctly ignored. |
| 1464 TEST_F(StatsCollectorTest, UnsupportedDigestIgnored) { | 1474 TEST_F(StatsCollectorTest, UnsupportedDigestIgnored) { |
| 1465 // Build a local certificate. | 1475 // Build a local certificate. |
| 1466 std::string local_der = "This is the local der."; | 1476 std::string local_der = "This is the local der."; |
| 1467 rtc::FakeSSLCertificate local_cert(DerToPem(local_der)); | 1477 rtc::FakeSSLCertificate local_cert(DerToPem(local_der)); |
| 1468 | 1478 |
| 1469 // Build a remote certificate with an unsupported digest algorithm. | 1479 // Build a remote certificate with an unsupported digest algorithm. |
| 1470 std::string remote_der = "This is somebody else's der."; | 1480 std::string remote_der = "This is somebody else's der."; |
| 1471 rtc::FakeSSLCertificate remote_cert(DerToPem(remote_der)); | 1481 rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert( |
| 1472 remote_cert.set_digest_algorithm("foobar"); | 1482 new rtc::FakeSSLCertificate(DerToPem(remote_der))); |
| 1483 remote_cert->set_digest_algorithm("foobar"); |
| 1473 | 1484 |
| 1474 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), | 1485 TestCertificateReports(local_cert, std::vector<std::string>(1, local_der), |
| 1475 remote_cert, std::vector<std::string>()); | 1486 std::move(remote_cert), std::vector<std::string>()); |
| 1476 } | 1487 } |
| 1477 | 1488 |
| 1478 // This test verifies that a local stats object can get statistics via | 1489 // This test verifies that a local stats object can get statistics via |
| 1479 // AudioTrackInterface::GetStats() method. | 1490 // AudioTrackInterface::GetStats() method. |
| 1480 TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { | 1491 TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) { |
| 1481 StatsCollectorForTest stats(&pc_); | 1492 StatsCollectorForTest stats(&pc_); |
| 1482 | 1493 |
| 1483 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1494 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1484 .WillRepeatedly(Return(false)); | 1495 .WillRepeatedly(Return(false)); |
| 1485 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1496 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1486 .WillRepeatedly(Return(false)); | 1497 .WillRepeatedly(Return(nullptr)); |
| 1487 | 1498 |
| 1488 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1499 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1489 // The transport_name known by the voice channel. | 1500 // The transport_name known by the voice channel. |
| 1490 const std::string kVcName("vcname"); | 1501 const std::string kVcName("vcname"); |
| 1491 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1502 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1492 media_channel, nullptr, kVcName, false); | 1503 media_channel, nullptr, kVcName, false); |
| 1493 AddOutgoingAudioTrackStats(); | 1504 AddOutgoingAudioTrackStats(); |
| 1494 stats.AddStream(stream_); | 1505 stats.AddStream(stream_); |
| 1495 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); | 1506 stats.AddLocalAudioTrack(audio_track_, kSsrcOfTrack); |
| 1496 | 1507 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1510 EXPECT_TRUE(remote_report == NULL); | 1521 EXPECT_TRUE(remote_report == NULL); |
| 1511 } | 1522 } |
| 1512 | 1523 |
| 1513 // This test verifies that audio receive streams populate stats reports | 1524 // This test verifies that audio receive streams populate stats reports |
| 1514 // correctly. | 1525 // correctly. |
| 1515 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { | 1526 TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) { |
| 1516 StatsCollectorForTest stats(&pc_); | 1527 StatsCollectorForTest stats(&pc_); |
| 1517 | 1528 |
| 1518 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1529 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1519 .WillRepeatedly(Return(false)); | 1530 .WillRepeatedly(Return(false)); |
| 1520 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1531 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1521 .WillRepeatedly(Return(false)); | 1532 .WillRepeatedly(Return(nullptr)); |
| 1522 | 1533 |
| 1523 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1534 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1524 // The transport_name known by the voice channel. | 1535 // The transport_name known by the voice channel. |
| 1525 const std::string kVcName("vcname"); | 1536 const std::string kVcName("vcname"); |
| 1526 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1537 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1527 media_channel, nullptr, kVcName, false); | 1538 media_channel, nullptr, kVcName, false); |
| 1528 AddIncomingAudioTrackStats(); | 1539 AddIncomingAudioTrackStats(); |
| 1529 stats.AddStream(stream_); | 1540 stats.AddStream(stream_); |
| 1530 | 1541 |
| 1531 cricket::VoiceReceiverInfo voice_receiver_info; | 1542 cricket::VoiceReceiverInfo voice_receiver_info; |
| 1532 InitVoiceReceiverInfo(&voice_receiver_info); | 1543 InitVoiceReceiverInfo(&voice_receiver_info); |
| 1533 voice_receiver_info.codec_name = "fake_codec"; | 1544 voice_receiver_info.codec_name = "fake_codec"; |
| 1534 | 1545 |
| 1535 cricket::VoiceMediaInfo stats_read; | 1546 cricket::VoiceMediaInfo stats_read; |
| 1536 StatsReports reports; // returned values. | 1547 StatsReports reports; // returned values. |
| 1537 SetupAndVerifyAudioTrackStats( | 1548 SetupAndVerifyAudioTrackStats( |
| 1538 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1549 audio_track_.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1539 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); | 1550 media_channel, NULL, &voice_receiver_info, &stats_read, &reports); |
| 1540 } | 1551 } |
| 1541 | 1552 |
| 1542 // This test verifies that a local stats object won't update its statistics | 1553 // This test verifies that a local stats object won't update its statistics |
| 1543 // after a RemoveLocalAudioTrack() call. | 1554 // after a RemoveLocalAudioTrack() call. |
| 1544 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { | 1555 TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { |
| 1545 StatsCollectorForTest stats(&pc_); | 1556 StatsCollectorForTest stats(&pc_); |
| 1546 | 1557 |
| 1547 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1558 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1548 .WillRepeatedly(Return(false)); | 1559 .WillRepeatedly(Return(false)); |
| 1549 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1560 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1550 .WillRepeatedly(Return(false)); | 1561 .WillRepeatedly(Return(nullptr)); |
| 1551 | 1562 |
| 1552 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1563 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1553 // The transport_name known by the voice channel. | 1564 // The transport_name known by the voice channel. |
| 1554 const std::string kVcName("vcname"); | 1565 const std::string kVcName("vcname"); |
| 1555 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1566 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1556 media_channel, nullptr, kVcName, false); | 1567 media_channel, nullptr, kVcName, false); |
| 1557 AddOutgoingAudioTrackStats(); | 1568 AddOutgoingAudioTrackStats(); |
| 1558 stats.AddStream(stream_); | 1569 stats.AddStream(stream_); |
| 1559 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); | 1570 stats.AddLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
| 1560 | 1571 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 VerifyVoiceSenderInfoReport(report, voice_sender_info); | 1611 VerifyVoiceSenderInfoReport(report, voice_sender_info); |
| 1601 } | 1612 } |
| 1602 | 1613 |
| 1603 // This test verifies that when ongoing and incoming audio tracks are using | 1614 // This test verifies that when ongoing and incoming audio tracks are using |
| 1604 // the same ssrc, they populate stats reports correctly. | 1615 // the same ssrc, they populate stats reports correctly. |
| 1605 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { | 1616 TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { |
| 1606 StatsCollectorForTest stats(&pc_); | 1617 StatsCollectorForTest stats(&pc_); |
| 1607 | 1618 |
| 1608 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1619 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1609 .WillRepeatedly(Return(false)); | 1620 .WillRepeatedly(Return(false)); |
| 1610 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1621 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1611 .WillRepeatedly(Return(false)); | 1622 .WillRepeatedly(Return(nullptr)); |
| 1612 | 1623 |
| 1613 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1624 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1614 // The transport_name known by the voice channel. | 1625 // The transport_name known by the voice channel. |
| 1615 const std::string kVcName("vcname"); | 1626 const std::string kVcName("vcname"); |
| 1616 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1627 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1617 media_channel, nullptr, kVcName, false); | 1628 media_channel, nullptr, kVcName, false); |
| 1618 | 1629 |
| 1619 // Create a local stream with a local audio track and adds it to the stats. | 1630 // Create a local stream with a local audio track and adds it to the stats. |
| 1620 AddOutgoingAudioTrackStats(); | 1631 AddOutgoingAudioTrackStats(); |
| 1621 stats.AddStream(stream_); | 1632 stats.AddStream(stream_); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 | 1698 |
| 1688 // This test verifies that when two outgoing audio tracks are using the same | 1699 // This test verifies that when two outgoing audio tracks are using the same |
| 1689 // ssrc at different times, they populate stats reports correctly. | 1700 // ssrc at different times, they populate stats reports correctly. |
| 1690 // TODO(xians): Figure out if it is possible to encapsulate the setup and | 1701 // TODO(xians): Figure out if it is possible to encapsulate the setup and |
| 1691 // avoid duplication of code in test cases. | 1702 // avoid duplication of code in test cases. |
| 1692 TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { | 1703 TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) { |
| 1693 StatsCollectorForTest stats(&pc_); | 1704 StatsCollectorForTest stats(&pc_); |
| 1694 | 1705 |
| 1695 EXPECT_CALL(session_, GetLocalCertificate(_, _)) | 1706 EXPECT_CALL(session_, GetLocalCertificate(_, _)) |
| 1696 .WillRepeatedly(Return(false)); | 1707 .WillRepeatedly(Return(false)); |
| 1697 EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _)) | 1708 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 1698 .WillRepeatedly(Return(false)); | 1709 .WillRepeatedly(Return(nullptr)); |
| 1699 | 1710 |
| 1700 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); | 1711 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel(); |
| 1701 // The transport_name known by the voice channel. | 1712 // The transport_name known by the voice channel. |
| 1702 const std::string kVcName("vcname"); | 1713 const std::string kVcName("vcname"); |
| 1703 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, | 1714 cricket::VoiceChannel voice_channel(rtc::Thread::Current(), media_engine_, |
| 1704 media_channel, nullptr, kVcName, false); | 1715 media_channel, nullptr, kVcName, false); |
| 1705 | 1716 |
| 1706 // Create a local stream with a local audio track and adds it to the stats. | 1717 // Create a local stream with a local audio track and adds it to the stats. |
| 1707 AddOutgoingAudioTrackStats(); | 1718 AddOutgoingAudioTrackStats(); |
| 1708 stats.AddStream(stream_); | 1719 stats.AddStream(stream_); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1734 cricket::VoiceSenderInfo new_voice_sender_info; | 1745 cricket::VoiceSenderInfo new_voice_sender_info; |
| 1735 InitVoiceSenderInfo(&new_voice_sender_info); | 1746 InitVoiceSenderInfo(&new_voice_sender_info); |
| 1736 cricket::VoiceMediaInfo new_stats_read; | 1747 cricket::VoiceMediaInfo new_stats_read; |
| 1737 reports.clear(); | 1748 reports.clear(); |
| 1738 SetupAndVerifyAudioTrackStats( | 1749 SetupAndVerifyAudioTrackStats( |
| 1739 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, | 1750 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, |
| 1740 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); | 1751 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); |
| 1741 } | 1752 } |
| 1742 | 1753 |
| 1743 } // namespace webrtc | 1754 } // namespace webrtc |
| OLD | NEW |