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

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

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: GetSessionStats replacing GetTransportStats, getting certificate from any thread 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(_)).WillRepeatedly(ReturnNull());
315 EXPECT_CALL(session_, GetLocalCertificate(_, _)).WillRepeatedly( 315 EXPECT_CALL(session_, GetLocalCertificate(_, _)).WillRepeatedly(
316 Return(false)); 316 Return(false));
317 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) 317 EXPECT_CALL(session_, GetRemoteSSLCertificate_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_; }
(...skipping 294 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(_)).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(_, _)).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 }));
(...skipping 60 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(_)).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(_)).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(_, _)).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") {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(_)).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(_, _)).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 }));
(...skipping 104 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(_)).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(_)).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(_)).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(_)).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(_)).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(_)).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(_)).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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
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