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

Side by Side Diff: webrtc/api/rtcstatscollector_unittest.cc

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 session_(media_controller_.get()), 304 session_(media_controller_.get()),
305 pc_() { 305 pc_() {
306 // Default return values for mocks. 306 // Default return values for mocks.
307 EXPECT_CALL(pc_, local_streams()).WillRepeatedly(Return(nullptr)); 307 EXPECT_CALL(pc_, local_streams()).WillRepeatedly(Return(nullptr));
308 EXPECT_CALL(pc_, remote_streams()).WillRepeatedly(Return(nullptr)); 308 EXPECT_CALL(pc_, remote_streams()).WillRepeatedly(Return(nullptr));
309 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_)); 309 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_));
310 EXPECT_CALL(pc_, sctp_data_channels()).WillRepeatedly( 310 EXPECT_CALL(pc_, sctp_data_channels()).WillRepeatedly(
311 ReturnRef(data_channels_)); 311 ReturnRef(data_channels_));
312 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); 312 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
313 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); 313 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull());
314 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); 314 EXPECT_CALL(session_, GetSessionStats_n(_)).WillRepeatedly(ReturnNull());
315 EXPECT_CALL(session_, GetLocalCertificate(_, _)).WillRepeatedly( 315 EXPECT_CALL(session_, GetLocalCertificate_n(_, _)).WillRepeatedly(
316 Return(false)); 316 Return(false));
317 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) 317 EXPECT_CALL(session_, GetRemoteSSLCertificate_n_ReturnsRawPointer(_))
318 .WillRepeatedly(Return(nullptr)); 318 .WillRepeatedly(Return(nullptr));
319 } 319 }
320 320
321 rtc::ScopedFakeClock& fake_clock() { return fake_clock_; } 321 rtc::ScopedFakeClock& fake_clock() { return fake_clock_; }
322 rtc::Thread* worker_thread() { return worker_thread_; } 322 rtc::Thread* worker_thread() { return worker_thread_; }
323 rtc::Thread* network_thread() { return network_thread_; } 323 rtc::Thread* network_thread() { return network_thread_; }
324 cricket::FakeMediaEngine* media_engine() { return media_engine_; } 324 cricket::FakeMediaEngine* media_engine() { return media_engine_; }
325 MockWebRtcSession& session() { return session_; } 325 MockWebRtcSession& session() { return session_; }
326 MockPeerConnection& pc() { return pc_; } 326 MockPeerConnection& pc() { return pc_; }
327 std::vector<rtc::scoped_refptr<DataChannel>>& data_channels() { 327 std::vector<rtc::scoped_refptr<DataChannel>>& data_channels() {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 619
620 TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) { 620 TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) {
621 std::unique_ptr<CertificateInfo> local_certinfo = 621 std::unique_ptr<CertificateInfo> local_certinfo =
622 CreateFakeCertificateAndInfoFromDers( 622 CreateFakeCertificateAndInfoFromDers(
623 std::vector<std::string>({ "(local) single certificate" })); 623 std::vector<std::string>({ "(local) single certificate" }));
624 std::unique_ptr<CertificateInfo> remote_certinfo = 624 std::unique_ptr<CertificateInfo> remote_certinfo =
625 CreateFakeCertificateAndInfoFromDers( 625 CreateFakeCertificateAndInfoFromDers(
626 std::vector<std::string>({ "(remote) single certificate" })); 626 std::vector<std::string>({ "(remote) single certificate" }));
627 627
628 // Mock the session to return the local and remote certificates. 628 // Mock the session to return the local and remote certificates.
629 EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke( 629 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
630 [this](SessionStats* stats) { 630 [this](const ChannelNamePairs&) {
631 std::unique_ptr<SessionStats> stats(new SessionStats());
631 stats->transport_stats["transport"].transport_name = "transport"; 632 stats->transport_stats["transport"].transport_name = "transport";
632 return true; 633 return stats;
633 })); 634 }));
634 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( 635 EXPECT_CALL(test_->session(), GetLocalCertificate_n(_, _)).WillRepeatedly(
635 Invoke([this, &local_certinfo](const std::string& transport_name, 636 Invoke([this, &local_certinfo](const std::string& transport_name,
636 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 637 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
637 if (transport_name == "transport") { 638 if (transport_name == "transport") {
638 *certificate = local_certinfo->certificate; 639 *certificate = local_certinfo->certificate;
639 return true; 640 return true;
640 } 641 }
641 return false; 642 return false;
642 })); 643 }));
643 EXPECT_CALL(test_->session(), 644 EXPECT_CALL(test_->session(),
644 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( 645 GetRemoteSSLCertificate_n_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
645 [this, &remote_certinfo](const std::string& transport_name) { 646 [this, &remote_certinfo](const std::string& transport_name) {
646 if (transport_name == "transport") 647 if (transport_name == "transport")
647 return remote_certinfo->certificate->ssl_certificate().GetReference(); 648 return remote_certinfo->certificate->ssl_certificate().GetReference();
648 return static_cast<rtc::SSLCertificate*>(nullptr); 649 return static_cast<rtc::SSLCertificate*>(nullptr);
649 })); 650 }));
650 651
651 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 652 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
652 ExpectReportContainsCertificateInfo(report, *local_certinfo.get()); 653 ExpectReportContainsCertificateInfo(report, *local_certinfo.get());
653 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get()); 654 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get());
654 } 655 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 704
704 EXPECT_CALL(*video_media_channel, GetStats(_)) 705 EXPECT_CALL(*video_media_channel, GetStats(_))
705 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); 706 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true)));
706 707
707 SessionStats session_stats; 708 SessionStats session_stats;
708 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; 709 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName";
709 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; 710 session_stats.proxy_to_transport["VideoContentName"] = "TransportName";
710 session_stats.transport_stats["TransportName"].transport_name = 711 session_stats.transport_stats["TransportName"].transport_name =
711 "TransportName"; 712 "TransportName";
712 713
713 EXPECT_CALL(test_->session(), GetTransportStats(_)) 714 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
714 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); 715 [&session_stats](const ChannelNamePairs&) {
716 return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
717 }));
715 EXPECT_CALL(test_->session(), voice_channel()) 718 EXPECT_CALL(test_->session(), voice_channel())
716 .WillRepeatedly(Return(&voice_channel)); 719 .WillRepeatedly(Return(&voice_channel));
717 EXPECT_CALL(test_->session(), video_channel()) 720 EXPECT_CALL(test_->session(), video_channel())
718 .WillRepeatedly(Return(&video_channel)); 721 .WillRepeatedly(Return(&video_channel));
719 722
720 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 723 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
721 724
722 RTCCodecStats expected_inbound_audio_codec( 725 RTCCodecStats expected_inbound_audio_codec(
723 "RTCCodec_InboundAudio_1", report->timestamp_us()); 726 "RTCCodec_InboundAudio_1", report->timestamp_us());
724 expected_inbound_audio_codec.payload_type = 1; 727 expected_inbound_audio_codec.payload_type = 1;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 std::vector<std::string>({ "(local) video" })); 784 std::vector<std::string>({ "(local) video" }));
782 video_local_certinfo = CreateFakeCertificateAndInfoFromDers( 785 video_local_certinfo = CreateFakeCertificateAndInfoFromDers(
783 video_local_certinfo->ders); 786 video_local_certinfo->ders);
784 std::unique_ptr<CertificateInfo> video_remote_certinfo = 787 std::unique_ptr<CertificateInfo> video_remote_certinfo =
785 CreateFakeCertificateAndInfoFromDers( 788 CreateFakeCertificateAndInfoFromDers(
786 std::vector<std::string>({ "(remote) video" })); 789 std::vector<std::string>({ "(remote) video" }));
787 video_remote_certinfo = CreateFakeCertificateAndInfoFromDers( 790 video_remote_certinfo = CreateFakeCertificateAndInfoFromDers(
788 video_remote_certinfo->ders); 791 video_remote_certinfo->ders);
789 792
790 // Mock the session to return the local and remote certificates. 793 // Mock the session to return the local and remote certificates.
791 EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke( 794 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
792 [this](SessionStats* stats) { 795 [this](const ChannelNamePairs&) {
796 std::unique_ptr<SessionStats> stats(new SessionStats());
793 stats->transport_stats["audio"].transport_name = "audio"; 797 stats->transport_stats["audio"].transport_name = "audio";
794 stats->transport_stats["video"].transport_name = "video"; 798 stats->transport_stats["video"].transport_name = "video";
795 return true; 799 return stats;
796 })); 800 }));
797 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( 801 EXPECT_CALL(test_->session(), GetLocalCertificate_n(_, _)).WillRepeatedly(
798 Invoke([this, &audio_local_certinfo, &video_local_certinfo]( 802 Invoke([this, &audio_local_certinfo, &video_local_certinfo](
799 const std::string& transport_name, 803 const std::string& transport_name,
800 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 804 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
801 if (transport_name == "audio") { 805 if (transport_name == "audio") {
802 *certificate = audio_local_certinfo->certificate; 806 *certificate = audio_local_certinfo->certificate;
803 return true; 807 return true;
804 } 808 }
805 if (transport_name == "video") { 809 if (transport_name == "video") {
806 *certificate = video_local_certinfo->certificate; 810 *certificate = video_local_certinfo->certificate;
807 return true; 811 return true;
808 } 812 }
809 return false; 813 return false;
810 })); 814 }));
811 EXPECT_CALL(test_->session(), 815 EXPECT_CALL(test_->session(),
812 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( 816 GetRemoteSSLCertificate_n_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
813 [this, &audio_remote_certinfo, &video_remote_certinfo]( 817 [this, &audio_remote_certinfo, &video_remote_certinfo](
814 const std::string& transport_name) { 818 const std::string& transport_name) {
815 if (transport_name == "audio") { 819 if (transport_name == "audio") {
816 return audio_remote_certinfo->certificate->ssl_certificate() 820 return audio_remote_certinfo->certificate->ssl_certificate()
817 .GetReference(); 821 .GetReference();
818 } 822 }
819 if (transport_name == "video") { 823 if (transport_name == "video") {
820 return video_remote_certinfo->certificate->ssl_certificate() 824 return video_remote_certinfo->certificate->ssl_certificate()
821 .GetReference(); 825 .GetReference();
822 } 826 }
(...skipping 17 matching lines...) Expand all
840 CreateFakeCertificateAndInfoFromDers(local_ders); 844 CreateFakeCertificateAndInfoFromDers(local_ders);
841 std::vector<std::string> remote_ders; 845 std::vector<std::string> remote_ders;
842 remote_ders.push_back("(remote) this"); 846 remote_ders.push_back("(remote) this");
843 remote_ders.push_back("(remote) is"); 847 remote_ders.push_back("(remote) is");
844 remote_ders.push_back("(remote) another"); 848 remote_ders.push_back("(remote) another");
845 remote_ders.push_back("(remote) chain"); 849 remote_ders.push_back("(remote) chain");
846 std::unique_ptr<CertificateInfo> remote_certinfo = 850 std::unique_ptr<CertificateInfo> remote_certinfo =
847 CreateFakeCertificateAndInfoFromDers(remote_ders); 851 CreateFakeCertificateAndInfoFromDers(remote_ders);
848 852
849 // Mock the session to return the local and remote certificates. 853 // Mock the session to return the local and remote certificates.
850 EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke( 854 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
851 [this](SessionStats* stats) { 855 [this](const ChannelNamePairs&) {
856 std::unique_ptr<SessionStats> stats(new SessionStats());
852 stats->transport_stats["transport"].transport_name = "transport"; 857 stats->transport_stats["transport"].transport_name = "transport";
853 return true; 858 return stats;
854 })); 859 }));
855 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( 860 EXPECT_CALL(test_->session(), GetLocalCertificate_n(_, _)).WillRepeatedly(
856 Invoke([this, &local_certinfo](const std::string& transport_name, 861 Invoke([this, &local_certinfo](const std::string& transport_name,
857 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 862 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
858 if (transport_name == "transport") { 863 if (transport_name == "transport") {
859 *certificate = local_certinfo->certificate; 864 *certificate = local_certinfo->certificate;
860 return true; 865 return true;
861 } 866 }
862 return false; 867 return false;
863 })); 868 }));
864 EXPECT_CALL(test_->session(), 869 EXPECT_CALL(test_->session(),
865 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( 870 GetRemoteSSLCertificate_n_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
866 [this, &remote_certinfo](const std::string& transport_name) { 871 [this, &remote_certinfo](const std::string& transport_name) {
867 if (transport_name == "transport") 872 if (transport_name == "transport")
868 return remote_certinfo->certificate->ssl_certificate().GetReference(); 873 return remote_certinfo->certificate->ssl_certificate().GetReference();
869 return static_cast<rtc::SSLCertificate*>(nullptr); 874 return static_cast<rtc::SSLCertificate*>(nullptr);
870 })); 875 }));
871 876
872 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 877 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
873 ExpectReportContainsCertificateInfo(report, *local_certinfo.get()); 878 ExpectReportContainsCertificateInfo(report, *local_certinfo.get());
874 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get()); 879 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get());
875 } 880 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 b_transport_channel_stats.connection_infos.push_back( 973 b_transport_channel_stats.connection_infos.push_back(
969 cricket::ConnectionInfo()); 974 cricket::ConnectionInfo());
970 b_transport_channel_stats.connection_infos[0].local_candidate = 975 b_transport_channel_stats.connection_infos[0].local_candidate =
971 *b_local.get(); 976 *b_local.get();
972 b_transport_channel_stats.connection_infos[0].remote_candidate = 977 b_transport_channel_stats.connection_infos[0].remote_candidate =
973 *b_remote.get(); 978 *b_remote.get();
974 session_stats.transport_stats["b"].channel_stats.push_back( 979 session_stats.transport_stats["b"].channel_stats.push_back(
975 b_transport_channel_stats); 980 b_transport_channel_stats);
976 981
977 // Mock the session to return the desired candidates. 982 // Mock the session to return the desired candidates.
978 EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke( 983 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
979 [this, &session_stats](SessionStats* stats) { 984 [&session_stats](const ChannelNamePairs&) {
980 *stats = session_stats; 985 return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
981 return true;
982 })); 986 }));
983 987
984 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 988 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
985 ExpectReportContainsCandidate(report, *a_local_host.get(), true); 989 ExpectReportContainsCandidate(report, *a_local_host.get(), true);
986 ExpectReportContainsCandidate(report, *a_remote_srflx.get(), false); 990 ExpectReportContainsCandidate(report, *a_remote_srflx.get(), false);
987 ExpectReportContainsCandidate(report, *a_local_prflx.get(), true); 991 ExpectReportContainsCandidate(report, *a_local_prflx.get(), true);
988 ExpectReportContainsCandidate(report, *a_remote_relay.get(), false); 992 ExpectReportContainsCandidate(report, *a_remote_relay.get(), false);
989 ExpectReportContainsCandidate(report, *b_local.get(), true); 993 ExpectReportContainsCandidate(report, *b_local.get(), true);
990 ExpectReportContainsCandidate(report, *b_remote.get(), false); 994 ExpectReportContainsCandidate(report, *b_remote.get(), false);
991 } 995 }
(...skipping 20 matching lines...) Expand all
1012 connection_info.sent_ping_responses = 1000; 1016 connection_info.sent_ping_responses = 1000;
1013 1017
1014 cricket::TransportChannelStats transport_channel_stats; 1018 cricket::TransportChannelStats transport_channel_stats;
1015 transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; 1019 transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
1016 transport_channel_stats.connection_infos.push_back(connection_info); 1020 transport_channel_stats.connection_infos.push_back(connection_info);
1017 session_stats.transport_stats["transport"].transport_name = "transport"; 1021 session_stats.transport_stats["transport"].transport_name = "transport";
1018 session_stats.transport_stats["transport"].channel_stats.push_back( 1022 session_stats.transport_stats["transport"].channel_stats.push_back(
1019 transport_channel_stats); 1023 transport_channel_stats);
1020 1024
1021 // Mock the session to return the desired candidates. 1025 // Mock the session to return the desired candidates.
1022 EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke( 1026 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
1023 [this, &session_stats](SessionStats* stats) { 1027 [&session_stats](const ChannelNamePairs&) {
1024 *stats = session_stats; 1028 return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
1025 return true;
1026 })); 1029 }));
1027 1030
1028 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 1031 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
1029 1032
1030 RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" + 1033 RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" +
1031 local_candidate->id() + "_" + 1034 local_candidate->id() + "_" +
1032 remote_candidate->id(), 1035 remote_candidate->id(),
1033 report->timestamp_us()); 1036 report->timestamp_us());
1034 expected_pair.transport_id = 1037 expected_pair.transport_id =
1035 "RTCTransport_transport_" + 1038 "RTCTransport_transport_" +
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; 1339 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName";
1337 session_stats.transport_stats["TransportName"].transport_name = 1340 session_stats.transport_stats["TransportName"].transport_name =
1338 "TransportName"; 1341 "TransportName";
1339 1342
1340 // Make sure the associated |RTCTransportStats| is created. 1343 // Make sure the associated |RTCTransportStats| is created.
1341 cricket::TransportChannelStats channel_stats; 1344 cricket::TransportChannelStats channel_stats;
1342 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; 1345 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
1343 session_stats.transport_stats["TransportName"].channel_stats.push_back( 1346 session_stats.transport_stats["TransportName"].channel_stats.push_back(
1344 channel_stats); 1347 channel_stats);
1345 1348
1346 EXPECT_CALL(test_->session(), GetTransportStats(_)) 1349 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
1347 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); 1350 [&session_stats](const ChannelNamePairs&) {
1351 return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
1352 }));
1348 EXPECT_CALL(test_->session(), voice_channel()) 1353 EXPECT_CALL(test_->session(), voice_channel())
1349 .WillRepeatedly(Return(&voice_channel)); 1354 .WillRepeatedly(Return(&voice_channel));
1350 1355
1351 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 1356 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
1352 1357
1353 RTCInboundRTPStreamStats expected_audio( 1358 RTCInboundRTPStreamStats expected_audio(
1354 "RTCInboundRTPAudioStream_1", report->timestamp_us()); 1359 "RTCInboundRTPAudioStream_1", report->timestamp_us());
1355 expected_audio.ssrc = "1"; 1360 expected_audio.ssrc = "1";
1356 expected_audio.is_remote = false; 1361 expected_audio.is_remote = false;
1357 expected_audio.media_type = "audio"; 1362 expected_audio.media_type = "audio";
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; 1413 session_stats.proxy_to_transport["VideoContentName"] = "TransportName";
1409 session_stats.transport_stats["TransportName"].transport_name = 1414 session_stats.transport_stats["TransportName"].transport_name =
1410 "TransportName"; 1415 "TransportName";
1411 1416
1412 // Make sure the associated |RTCTransportStats| is created. 1417 // Make sure the associated |RTCTransportStats| is created.
1413 cricket::TransportChannelStats channel_stats; 1418 cricket::TransportChannelStats channel_stats;
1414 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; 1419 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
1415 session_stats.transport_stats["TransportName"].channel_stats.push_back( 1420 session_stats.transport_stats["TransportName"].channel_stats.push_back(
1416 channel_stats); 1421 channel_stats);
1417 1422
1418 EXPECT_CALL(test_->session(), GetTransportStats(_)) 1423 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
1419 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); 1424 [&session_stats](const ChannelNamePairs&) {
1425 return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
1426 }));
1420 EXPECT_CALL(test_->session(), video_channel()) 1427 EXPECT_CALL(test_->session(), video_channel())
1421 .WillRepeatedly(Return(&video_channel)); 1428 .WillRepeatedly(Return(&video_channel));
1422 1429
1423 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 1430 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
1424 1431
1425 RTCInboundRTPStreamStats expected_video( 1432 RTCInboundRTPStreamStats expected_video(
1426 "RTCInboundRTPVideoStream_1", report->timestamp_us()); 1433 "RTCInboundRTPVideoStream_1", report->timestamp_us());
1427 expected_video.ssrc = "1"; 1434 expected_video.ssrc = "1";
1428 expected_video.is_remote = false; 1435 expected_video.is_remote = false;
1429 expected_video.media_type = "video"; 1436 expected_video.media_type = "video";
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName"; 1484 session_stats.proxy_to_transport["VoiceContentName"] = "TransportName";
1478 session_stats.transport_stats["TransportName"].transport_name = 1485 session_stats.transport_stats["TransportName"].transport_name =
1479 "TransportName"; 1486 "TransportName";
1480 1487
1481 // Make sure the associated |RTCTransportStats| is created. 1488 // Make sure the associated |RTCTransportStats| is created.
1482 cricket::TransportChannelStats channel_stats; 1489 cricket::TransportChannelStats channel_stats;
1483 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; 1490 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
1484 session_stats.transport_stats["TransportName"].channel_stats.push_back( 1491 session_stats.transport_stats["TransportName"].channel_stats.push_back(
1485 channel_stats); 1492 channel_stats);
1486 1493
1487 EXPECT_CALL(test_->session(), GetTransportStats(_)) 1494 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
1488 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); 1495 [&session_stats](const ChannelNamePairs&) {
1496 return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
1497 }));
1489 EXPECT_CALL(test_->session(), voice_channel()) 1498 EXPECT_CALL(test_->session(), voice_channel())
1490 .WillRepeatedly(Return(&voice_channel)); 1499 .WillRepeatedly(Return(&voice_channel));
1491 1500
1492 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 1501 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
1493 1502
1494 RTCOutboundRTPStreamStats expected_audio( 1503 RTCOutboundRTPStreamStats expected_audio(
1495 "RTCOutboundRTPAudioStream_1", report->timestamp_us()); 1504 "RTCOutboundRTPAudioStream_1", report->timestamp_us());
1496 expected_audio.ssrc = "1"; 1505 expected_audio.ssrc = "1";
1497 expected_audio.is_remote = false; 1506 expected_audio.is_remote = false;
1498 expected_audio.media_type = "audio"; 1507 expected_audio.media_type = "audio";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 session_stats.proxy_to_transport["VideoContentName"] = "TransportName"; 1554 session_stats.proxy_to_transport["VideoContentName"] = "TransportName";
1546 session_stats.transport_stats["TransportName"].transport_name = 1555 session_stats.transport_stats["TransportName"].transport_name =
1547 "TransportName"; 1556 "TransportName";
1548 1557
1549 // Make sure the associated |RTCTransportStats| is created. 1558 // Make sure the associated |RTCTransportStats| is created.
1550 cricket::TransportChannelStats channel_stats; 1559 cricket::TransportChannelStats channel_stats;
1551 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; 1560 channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
1552 session_stats.transport_stats["TransportName"].channel_stats.push_back( 1561 session_stats.transport_stats["TransportName"].channel_stats.push_back(
1553 channel_stats); 1562 channel_stats);
1554 1563
1555 EXPECT_CALL(test_->session(), GetTransportStats(_)) 1564 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
1556 .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true))); 1565 [&session_stats](const ChannelNamePairs&) {
1566 return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
1567 }));
1557 EXPECT_CALL(test_->session(), video_channel()) 1568 EXPECT_CALL(test_->session(), video_channel())
1558 .WillRepeatedly(Return(&video_channel)); 1569 .WillRepeatedly(Return(&video_channel));
1559 1570
1560 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 1571 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
1561 1572
1562 RTCOutboundRTPStreamStats expected_video( 1573 RTCOutboundRTPStreamStats expected_video(
1563 "RTCOutboundRTPVideoStream_1", report->timestamp_us()); 1574 "RTCOutboundRTPVideoStream_1", report->timestamp_us());
1564 expected_video.ssrc = "1"; 1575 expected_video.ssrc = "1";
1565 expected_video.is_remote = false; 1576 expected_video.is_remote = false;
1566 expected_video.media_type = "video"; 1577 expected_video.media_type = "video";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 rtp_connection_info.sent_total_bytes = 42; 1617 rtp_connection_info.sent_total_bytes = 42;
1607 rtp_connection_info.recv_total_bytes = 1337; 1618 rtp_connection_info.recv_total_bytes = 1337;
1608 cricket::TransportChannelStats rtp_transport_channel_stats; 1619 cricket::TransportChannelStats rtp_transport_channel_stats;
1609 rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; 1620 rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
1610 rtp_transport_channel_stats.connection_infos.push_back(rtp_connection_info); 1621 rtp_transport_channel_stats.connection_infos.push_back(rtp_connection_info);
1611 session_stats.transport_stats["transport"].channel_stats.push_back( 1622 session_stats.transport_stats["transport"].channel_stats.push_back(
1612 rtp_transport_channel_stats); 1623 rtp_transport_channel_stats);
1613 1624
1614 1625
1615 // Mock the session to return the desired candidates. 1626 // Mock the session to return the desired candidates.
1616 EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke( 1627 EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
1617 [this, &session_stats](SessionStats* stats) { 1628 [&session_stats](const ChannelNamePairs&) {
1618 *stats = session_stats; 1629 return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
1619 return true;
1620 })); 1630 }));
1621 1631
1622 // Get stats without RTCP, an active connection or certificates. 1632 // Get stats without RTCP, an active connection or certificates.
1623 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 1633 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
1624 1634
1625 RTCTransportStats expected_rtp_transport( 1635 RTCTransportStats expected_rtp_transport(
1626 "RTCTransport_transport_" + 1636 "RTCTransport_transport_" +
1627 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP), 1637 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP),
1628 report->timestamp_us()); 1638 report->timestamp_us());
1629 expected_rtp_transport.bytes_sent = 42; 1639 expected_rtp_transport.bytes_sent = 42;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 expected_rtcp_transport, 1704 expected_rtcp_transport,
1695 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); 1705 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>());
1696 1706
1697 // Get stats with certificates. 1707 // Get stats with certificates.
1698 std::unique_ptr<CertificateInfo> local_certinfo = 1708 std::unique_ptr<CertificateInfo> local_certinfo =
1699 CreateFakeCertificateAndInfoFromDers( 1709 CreateFakeCertificateAndInfoFromDers(
1700 std::vector<std::string>({ "(local) local", "(local) chain" })); 1710 std::vector<std::string>({ "(local) local", "(local) chain" }));
1701 std::unique_ptr<CertificateInfo> remote_certinfo = 1711 std::unique_ptr<CertificateInfo> remote_certinfo =
1702 CreateFakeCertificateAndInfoFromDers( 1712 CreateFakeCertificateAndInfoFromDers(
1703 std::vector<std::string>({ "(remote) local", "(remote) chain" })); 1713 std::vector<std::string>({ "(remote) local", "(remote) chain" }));
1704 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( 1714 EXPECT_CALL(test_->session(), GetLocalCertificate_n(_, _)).WillRepeatedly(
1705 Invoke([this, &local_certinfo](const std::string& transport_name, 1715 Invoke([this, &local_certinfo](const std::string& transport_name,
1706 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 1716 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
1707 if (transport_name == "transport") { 1717 if (transport_name == "transport") {
1708 *certificate = local_certinfo->certificate; 1718 *certificate = local_certinfo->certificate;
1709 return true; 1719 return true;
1710 } 1720 }
1711 return false; 1721 return false;
1712 })); 1722 }));
1713 EXPECT_CALL(test_->session(), 1723 EXPECT_CALL(test_->session(),
1714 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( 1724 GetRemoteSSLCertificate_n_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
1715 [this, &remote_certinfo](const std::string& transport_name) { 1725 [this, &remote_certinfo](const std::string& transport_name) {
1716 if (transport_name == "transport") 1726 if (transport_name == "transport")
1717 return remote_certinfo->certificate->ssl_certificate().GetReference(); 1727 return remote_certinfo->certificate->ssl_certificate().GetReference();
1718 return static_cast<rtc::SSLCertificate*>(nullptr); 1728 return static_cast<rtc::SSLCertificate*>(nullptr);
1719 })); 1729 }));
1720 1730
1721 collector_->ClearCachedStatsReport(); 1731 collector_->ClearCachedStatsReport();
1722 report = GetStatsReport(); 1732 report = GetStatsReport();
1723 1733
1724 expected_rtp_transport.local_certificate_id = 1734 expected_rtp_transport.local_certificate_id =
(...skipping 29 matching lines...) Expand all
1754 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; 1764 rtc::scoped_refptr<FakeRTCStatsCollector> collector_;
1755 }; 1765 };
1756 1766
1757 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { 1767 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) {
1758 collector_->VerifyThreadUsageAndResultsMerging(); 1768 collector_->VerifyThreadUsageAndResultsMerging();
1759 } 1769 }
1760 1770
1761 } // namespace 1771 } // namespace
1762 1772
1763 } // namespace webrtc 1773 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698