Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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 13 matching lines...) Expand all Loading... | |
| 24 #include "webrtc/base/fakeclock.h" | 24 #include "webrtc/base/fakeclock.h" | 
| 25 #include "webrtc/base/fakesslidentity.h" | 25 #include "webrtc/base/fakesslidentity.h" | 
| 26 #include "webrtc/base/gunit.h" | 26 #include "webrtc/base/gunit.h" | 
| 27 #include "webrtc/base/logging.h" | 27 #include "webrtc/base/logging.h" | 
| 28 #include "webrtc/base/socketaddress.h" | 28 #include "webrtc/base/socketaddress.h" | 
| 29 #include "webrtc/base/thread_checker.h" | 29 #include "webrtc/base/thread_checker.h" | 
| 30 #include "webrtc/base/timedelta.h" | 30 #include "webrtc/base/timedelta.h" | 
| 31 #include "webrtc/base/timeutils.h" | 31 #include "webrtc/base/timeutils.h" | 
| 32 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 32 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 
| 33 #include "webrtc/media/base/fakemediaengine.h" | 33 #include "webrtc/media/base/fakemediaengine.h" | 
| 34 #include "webrtc/p2p/base/p2pconstants.h" | |
| 34 #include "webrtc/p2p/base/port.h" | 35 #include "webrtc/p2p/base/port.h" | 
| 35 | 36 | 
| 36 using testing::_; | 37 using testing::_; | 
| 37 using testing::Invoke; | 38 using testing::Invoke; | 
| 38 using testing::Return; | 39 using testing::Return; | 
| 39 using testing::ReturnRef; | 40 using testing::ReturnRef; | 
| 40 | 41 | 
| 41 namespace webrtc { | 42 namespace webrtc { | 
| 42 | 43 | 
| 43 namespace { | 44 namespace { | 
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 | 358 | 
| 358 void ExpectReportContainsCandidatePair( | 359 void ExpectReportContainsCandidatePair( | 
| 359 const rtc::scoped_refptr<const RTCStatsReport>& report, | 360 const rtc::scoped_refptr<const RTCStatsReport>& report, | 
| 360 const cricket::TransportStats& transport_stats) { | 361 const cricket::TransportStats& transport_stats) { | 
| 361 for (const auto& channel_stats : transport_stats.channel_stats) { | 362 for (const auto& channel_stats : transport_stats.channel_stats) { | 
| 362 for (const cricket::ConnectionInfo& info : | 363 for (const cricket::ConnectionInfo& info : | 
| 363 channel_stats.connection_infos) { | 364 channel_stats.connection_infos) { | 
| 364 const std::string& id = "RTCIceCandidatePair_" + | 365 const std::string& id = "RTCIceCandidatePair_" + | 
| 365 info.local_candidate.id() + "_" + info.remote_candidate.id(); | 366 info.local_candidate.id() + "_" + info.remote_candidate.id(); | 
| 366 const RTCStats* stats = report->Get(id); | 367 const RTCStats* stats = report->Get(id); | 
| 367 EXPECT_TRUE(stats); | 368 ASSERT_TRUE(stats); | 
| 368 const RTCIceCandidatePairStats& candidate_pair_stats = | 369 const RTCIceCandidatePairStats& candidate_pair_stats = | 
| 369 stats->cast_to<RTCIceCandidatePairStats>(); | 370 stats->cast_to<RTCIceCandidatePairStats>(); | 
| 370 | 371 | 
| 371 // TODO(hbos): Define all the undefined |candidate_pair_stats| stats. | 372 // TODO(hbos): Define all the undefined |candidate_pair_stats| stats. | 
| 372 // The EXPECT_FALSE are for the undefined stats, see also todos listed | 373 // The EXPECT_FALSE are for the undefined stats, see also todos listed | 
| 373 // in rtcstatscollector.cc. crbug.com/633550 | 374 // in rtcstatscollector.cc. crbug.com/633550 | 
| 374 EXPECT_FALSE(candidate_pair_stats.transport_id.is_defined()); | 375 EXPECT_FALSE(candidate_pair_stats.transport_id.is_defined()); | 
| 375 const RTCIceCandidateStats* local_candidate = | 376 const RTCIceCandidateStats* local_candidate = | 
| 376 ExpectReportContainsCandidate(report, info.local_candidate, true); | 377 ExpectReportContainsCandidate(report, info.local_candidate, true); | 
| 377 EXPECT_EQ(*candidate_pair_stats.local_candidate_id, | 378 EXPECT_EQ(*candidate_pair_stats.local_candidate_id, | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 } | 417 } | 
| 417 } | 418 } | 
| 418 } | 419 } | 
| 419 | 420 | 
| 420 void ExpectReportContainsCertificateInfo( | 421 void ExpectReportContainsCertificateInfo( | 
| 421 const rtc::scoped_refptr<const RTCStatsReport>& report, | 422 const rtc::scoped_refptr<const RTCStatsReport>& report, | 
| 422 const CertificateInfo& cert_info) { | 423 const CertificateInfo& cert_info) { | 
| 423 for (size_t i = 0; i < cert_info.fingerprints.size(); ++i) { | 424 for (size_t i = 0; i < cert_info.fingerprints.size(); ++i) { | 
| 424 const RTCStats* stats = report->Get( | 425 const RTCStats* stats = report->Get( | 
| 425 "RTCCertificate_" + cert_info.fingerprints[i]); | 426 "RTCCertificate_" + cert_info.fingerprints[i]); | 
| 426 EXPECT_TRUE(stats); | 427 ASSERT_TRUE(stats); | 
| 427 const RTCCertificateStats& cert_stats = | 428 const RTCCertificateStats& cert_stats = | 
| 428 stats->cast_to<const RTCCertificateStats>(); | 429 stats->cast_to<const RTCCertificateStats>(); | 
| 429 EXPECT_EQ(*cert_stats.fingerprint, cert_info.fingerprints[i]); | 430 EXPECT_EQ(*cert_stats.fingerprint, cert_info.fingerprints[i]); | 
| 430 EXPECT_EQ(*cert_stats.fingerprint_algorithm, "sha-1"); | 431 EXPECT_EQ(*cert_stats.fingerprint_algorithm, "sha-1"); | 
| 431 EXPECT_EQ(*cert_stats.base64_certificate, cert_info.pems[i]); | 432 EXPECT_EQ(*cert_stats.base64_certificate, cert_info.pems[i]); | 
| 432 if (i + 1 < cert_info.fingerprints.size()) { | 433 if (i + 1 < cert_info.fingerprints.size()) { | 
| 433 EXPECT_EQ(*cert_stats.issuer_certificate_id, | 434 EXPECT_EQ(*cert_stats.issuer_certificate_id, | 
| 434 "RTCCertificate_" + cert_info.fingerprints[i + 1]); | 435 "RTCCertificate_" + cert_info.fingerprints[i + 1]); | 
| 435 } else { | 436 } else { | 
| 436 EXPECT_FALSE(cert_stats.issuer_certificate_id.is_defined()); | 437 EXPECT_FALSE(cert_stats.issuer_certificate_id.is_defined()); | 
| 437 } | 438 } | 
| 438 } | 439 } | 
| 439 } | 440 } | 
| 440 | 441 | 
| 442 void ExpectReportContainsTransportStats( | |
| 443 const rtc::scoped_refptr<const RTCStatsReport>& report, | |
| 444 const cricket::TransportStats& transport, | |
| 445 const CertificateInfo* local_certinfo, | |
| 446 const CertificateInfo* remote_certinfo) { | |
| 447 std::string rtcp_transport_stats_id; | |
| 448 for (const auto& channel_stats : transport.channel_stats) { | |
| 449 if (channel_stats.component == cricket::ICE_CANDIDATE_COMPONENT_RTCP) { | |
| 450 rtcp_transport_stats_id = "RTCTransport_" + transport.transport_name + | |
| 451 "_" + rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTCP); | |
| 452 } | |
| 453 } | |
| 454 for (const auto& channel_stats : transport.channel_stats) { | |
| 455 const cricket::ConnectionInfo* best_connection_info = nullptr; | |
| 456 const RTCStats* stats = report->Get( | |
| 457 "RTCTransport_" + transport.transport_name + "_" + | |
| 458 rtc::ToString<>(channel_stats.component)); | |
| 459 ASSERT_TRUE(stats); | |
| 460 const RTCTransportStats& transport_stats = | |
| 461 stats->cast_to<const RTCTransportStats>(); | |
| 462 uint64_t bytes_sent = 0; | |
| 463 uint64_t bytes_received = 0; | |
| 464 for (const cricket::ConnectionInfo& info : | |
| 465 channel_stats.connection_infos) { | |
| 466 bytes_sent += info.sent_total_bytes; | |
| 467 bytes_received += info.recv_total_bytes; | |
| 468 if (info.best_connection) | |
| 469 best_connection_info = &info; | |
| 470 } | |
| 471 EXPECT_EQ(*transport_stats.bytes_sent, bytes_sent); | |
| 472 EXPECT_EQ(*transport_stats.bytes_received, bytes_received); | |
| 473 if (best_connection_info) { | |
| 474 EXPECT_EQ(*transport_stats.active_connection, true); | |
| 475 EXPECT_EQ(*transport_stats.selected_candidate_pair_id, | |
| 476 "RTCIceCandidatePair_" + | |
| 477 best_connection_info->local_candidate.id() + "_" + | |
| 478 best_connection_info->remote_candidate.id()); | |
| 
 
hta-webrtc
2016/10/21 08:37:51
I'm a bit skeptical of this method of testing that
 
hbos_chromium
2016/10/21 16:56:06
Added TODO.
 
 | |
| 479 EXPECT_TRUE(report->Get(*transport_stats.selected_candidate_pair_id)); | |
| 480 } else { | |
| 481 EXPECT_EQ(*transport_stats.active_connection, false); | |
| 482 EXPECT_FALSE(transport_stats.selected_candidate_pair_id.is_defined()); | |
| 483 } | |
| 484 if (channel_stats.component != cricket::ICE_CANDIDATE_COMPONENT_RTCP && | |
| 485 !rtcp_transport_stats_id.empty()) { | |
| 486 EXPECT_EQ(*transport_stats.rtcp_transport_stats_id, | |
| 487 rtcp_transport_stats_id); | |
| 488 } else { | |
| 489 EXPECT_FALSE(transport_stats.rtcp_transport_stats_id.is_defined()); | |
| 490 } | |
| 491 if (local_certinfo && remote_certinfo) { | |
| 492 EXPECT_EQ(*transport_stats.local_certificate_id, | |
| 493 "RTCCertificate_" + local_certinfo->fingerprints[0]); | |
| 494 EXPECT_EQ(*transport_stats.remote_certificate_id, | |
| 495 "RTCCertificate_" + remote_certinfo->fingerprints[0]); | |
| 496 EXPECT_TRUE(report->Get(*transport_stats.local_certificate_id)); | |
| 497 EXPECT_TRUE(report->Get(*transport_stats.remote_certificate_id)); | |
| 498 } else { | |
| 499 EXPECT_FALSE(transport_stats.local_certificate_id.is_defined()); | |
| 500 EXPECT_FALSE(transport_stats.remote_certificate_id.is_defined()); | |
| 501 } | |
| 502 } | |
| 503 } | |
| 504 | |
| 441 protected: | 505 protected: | 
| 442 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; | 506 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; | 
| 443 rtc::scoped_refptr<RTCStatsCollector> collector_; | 507 rtc::scoped_refptr<RTCStatsCollector> collector_; | 
| 444 }; | 508 }; | 
| 445 | 509 | 
| 446 TEST_F(RTCStatsCollectorTest, SingleCallback) { | 510 TEST_F(RTCStatsCollectorTest, SingleCallback) { | 
| 447 rtc::scoped_refptr<const RTCStatsReport> result; | 511 rtc::scoped_refptr<const RTCStatsReport> result; | 
| 448 collector_->GetStatsReport(StatsCallback::Create(&result)); | 512 collector_->GetStatsReport(StatsCallback::Create(&result)); | 
| 449 EXPECT_TRUE_WAIT(result, kGetStatsReportTimeoutMs); | 513 EXPECT_TRUE_WAIT(result, kGetStatsReportTimeoutMs); | 
| 450 } | 514 } | 
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 report, session_stats.transport_stats["transport"]); | 822 report, session_stats.transport_stats["transport"]); | 
| 759 } | 823 } | 
| 760 | 824 | 
| 761 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { | 825 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { | 
| 762 int64_t before = rtc::TimeUTCMicros(); | 826 int64_t before = rtc::TimeUTCMicros(); | 
| 763 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 827 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 
| 764 int64_t after = rtc::TimeUTCMicros(); | 828 int64_t after = rtc::TimeUTCMicros(); | 
| 765 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), | 829 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), | 
| 766 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; | 830 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; | 
| 767 const RTCStats* stats = report->Get("RTCPeerConnection"); | 831 const RTCStats* stats = report->Get("RTCPeerConnection"); | 
| 768 EXPECT_TRUE(stats); | 832 ASSERT_TRUE(stats); | 
| 769 EXPECT_LE(before, stats->timestamp_us()); | 833 EXPECT_LE(before, stats->timestamp_us()); | 
| 770 EXPECT_LE(stats->timestamp_us(), after); | 834 EXPECT_LE(stats->timestamp_us(), after); | 
| 771 { | 835 { | 
| 772 // Expected stats with no data channels | 836 // Expected stats with no data channels | 
| 773 const RTCPeerConnectionStats& pcstats = | 837 const RTCPeerConnectionStats& pcstats = | 
| 774 stats->cast_to<RTCPeerConnectionStats>(); | 838 stats->cast_to<RTCPeerConnectionStats>(); | 
| 775 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(0)); | 839 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(0)); | 
| 776 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(0)); | 840 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(0)); | 
| 777 } | 841 } | 
| 778 | 842 | 
| 779 test_->data_channels().push_back( | 843 test_->data_channels().push_back( | 
| 780 new MockDataChannel(DataChannelInterface::kConnecting)); | 844 new MockDataChannel(DataChannelInterface::kConnecting)); | 
| 781 test_->data_channels().push_back( | 845 test_->data_channels().push_back( | 
| 782 new MockDataChannel(DataChannelInterface::kOpen)); | 846 new MockDataChannel(DataChannelInterface::kOpen)); | 
| 783 test_->data_channels().push_back( | 847 test_->data_channels().push_back( | 
| 784 new MockDataChannel(DataChannelInterface::kClosing)); | 848 new MockDataChannel(DataChannelInterface::kClosing)); | 
| 785 test_->data_channels().push_back( | 849 test_->data_channels().push_back( | 
| 786 new MockDataChannel(DataChannelInterface::kClosed)); | 850 new MockDataChannel(DataChannelInterface::kClosed)); | 
| 787 | 851 | 
| 788 collector_->ClearCachedStatsReport(); | 852 collector_->ClearCachedStatsReport(); | 
| 789 report = GetStatsReport(); | 853 report = GetStatsReport(); | 
| 790 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), | 854 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), | 
| 791 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; | 855 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; | 
| 792 stats = report->Get("RTCPeerConnection"); | 856 stats = report->Get("RTCPeerConnection"); | 
| 793 EXPECT_TRUE(stats); | 857 ASSERT_TRUE(stats); | 
| 794 { | 858 { | 
| 795 // Expected stats with the above four data channels | 859 // Expected stats with the above four data channels | 
| 796 // TODO(hbos): When the |RTCPeerConnectionStats| is the number of data | 860 // TODO(hbos): When the |RTCPeerConnectionStats| is the number of data | 
| 797 // channels that have been opened and closed, not the numbers currently | 861 // channels that have been opened and closed, not the numbers currently | 
| 798 // open/closed, we would expect opened >= closed and (opened - closed) to be | 862 // open/closed, we would expect opened >= closed and (opened - closed) to be | 
| 799 // the number currently open. crbug.com/636818. | 863 // the number currently open. crbug.com/636818. | 
| 800 const RTCPeerConnectionStats& pcstats = | 864 const RTCPeerConnectionStats& pcstats = | 
| 801 stats->cast_to<RTCPeerConnectionStats>(); | 865 stats->cast_to<RTCPeerConnectionStats>(); | 
| 802 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); | 866 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); | 
| 803 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); | 867 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); | 
| 804 } | 868 } | 
| 805 } | 869 } | 
| 806 | 870 | 
| 871 TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) { | |
| 872 std::unique_ptr<cricket::Candidate> rtp_local_candidate = CreateFakeCandidate( | |
| 873 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42); | |
| 874 std::unique_ptr<cricket::Candidate> rtp_remote_candidate = | |
| 875 CreateFakeCandidate("42.42.42.42", 42, "protocol", | |
| 876 cricket::LOCAL_PORT_TYPE, 42); | |
| 877 std::unique_ptr<cricket::Candidate> rtcp_local_candidate = | |
| 878 CreateFakeCandidate("42.42.42.42", 42, "protocol", | |
| 879 cricket::LOCAL_PORT_TYPE, 42); | |
| 880 std::unique_ptr<cricket::Candidate> rtcp_remote_candidate = | |
| 881 CreateFakeCandidate("42.42.42.42", 42, "protocol", | |
| 882 cricket::LOCAL_PORT_TYPE, 42); | |
| 883 | |
| 884 SessionStats session_stats; | |
| 885 session_stats.transport_stats["transport"].transport_name = "transport"; | |
| 886 | |
| 887 cricket::ConnectionInfo rtp_connection_info; | |
| 888 rtp_connection_info.best_connection = false; | |
| 889 rtp_connection_info.local_candidate = *rtp_local_candidate.get(); | |
| 890 rtp_connection_info.remote_candidate = *rtp_remote_candidate.get(); | |
| 891 rtp_connection_info.sent_total_bytes = 42; | |
| 892 rtp_connection_info.recv_total_bytes = 1337; | |
| 893 cricket::TransportChannelStats rtp_transport_channel_stats; | |
| 894 rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | |
| 895 rtp_transport_channel_stats.connection_infos.push_back(rtp_connection_info); | |
| 896 session_stats.transport_stats["transport"].channel_stats.push_back( | |
| 897 rtp_transport_channel_stats); | |
| 898 | |
| 899 | |
| 900 // Mock the session to return the desired candidates. | |
| 901 EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke( | |
| 902 [this, &session_stats](SessionStats* stats) { | |
| 903 *stats = session_stats; | |
| 904 return true; | |
| 905 })); | |
| 906 | |
| 907 // Get stats without RTCP, an active connection or certificates. | |
| 908 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | |
| 909 ExpectReportContainsTransportStats( | |
| 910 report, session_stats.transport_stats["transport"], nullptr, nullptr); | |
| 911 | |
| 912 // Get stats with RTCP and without an active connection or certificates. | |
| 
 
Taylor Brandstetter
2016/10/19 19:03:07
nit: For consistency, should this comment go above
 
hta-webrtc
2016/10/21 08:37:51
Agree that comment seems misplaced. This stuff set
 
hbos_chromium
2016/10/21 16:56:06
Done.
 
 | |
| 913 cricket::ConnectionInfo rtcp_connection_info; | |
| 914 rtcp_connection_info.best_connection = false; | |
| 915 rtcp_connection_info.local_candidate = *rtcp_local_candidate.get(); | |
| 916 rtcp_connection_info.remote_candidate = *rtcp_remote_candidate.get(); | |
| 917 rtcp_connection_info.sent_total_bytes = 1337; | |
| 918 rtcp_connection_info.recv_total_bytes = 42; | |
| 919 cricket::TransportChannelStats rtcp_transport_channel_stats; | |
| 920 rtcp_transport_channel_stats.component = | |
| 921 cricket::ICE_CANDIDATE_COMPONENT_RTCP; | |
| 922 rtcp_transport_channel_stats.connection_infos.push_back(rtcp_connection_info); | |
| 923 session_stats.transport_stats["transport"].channel_stats.push_back( | |
| 924 rtcp_transport_channel_stats); | |
| 925 | |
| 926 // Get stats without an active connection or certificates. | |
| 927 collector_->ClearCachedStatsReport(); | |
| 928 report = GetStatsReport(); | |
| 929 ExpectReportContainsTransportStats( | |
| 930 report, session_stats.transport_stats["transport"], nullptr, nullptr); | |
| 931 | |
| 932 // Get stats with an active connection. | |
| 933 rtcp_connection_info.best_connection = true; | |
| 934 | |
| 935 collector_->ClearCachedStatsReport(); | |
| 936 report = GetStatsReport(); | |
| 937 ExpectReportContainsTransportStats( | |
| 938 report, session_stats.transport_stats["transport"], nullptr, nullptr); | |
| 939 | |
| 940 // Get stats with certificates. | |
| 941 std::unique_ptr<CertificateInfo> local_certinfo = | |
| 942 CreateFakeCertificateAndInfoFromDers( | |
| 943 std::vector<std::string>({ "(local) local", "(local) chain" })); | |
| 944 std::unique_ptr<CertificateInfo> remote_certinfo = | |
| 945 CreateFakeCertificateAndInfoFromDers( | |
| 946 std::vector<std::string>({ "(remote) local", "(remote) chain" })); | |
| 947 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( | |
| 948 Invoke([this, &local_certinfo](const std::string& transport_name, | |
| 949 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { | |
| 950 if (transport_name == "transport") { | |
| 951 *certificate = local_certinfo->certificate; | |
| 952 return true; | |
| 953 } | |
| 954 return false; | |
| 955 })); | |
| 956 EXPECT_CALL(test_->session(), | |
| 957 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( | |
| 958 [this, &remote_certinfo](const std::string& transport_name) { | |
| 959 if (transport_name == "transport") | |
| 960 return remote_certinfo->certificate->ssl_certificate().GetReference(); | |
| 961 return static_cast<rtc::SSLCertificate*>(nullptr); | |
| 962 })); | |
| 963 | |
| 964 collector_->ClearCachedStatsReport(); | |
| 965 report = GetStatsReport(); | |
| 966 ExpectReportContainsTransportStats( | |
| 967 report, session_stats.transport_stats["transport"], | |
| 968 local_certinfo.get(), remote_certinfo.get()); | |
| 969 } | |
| 970 | |
| 807 class RTCStatsCollectorTestWithFakeCollector : public testing::Test { | 971 class RTCStatsCollectorTestWithFakeCollector : public testing::Test { | 
| 808 public: | 972 public: | 
| 809 RTCStatsCollectorTestWithFakeCollector() | 973 RTCStatsCollectorTestWithFakeCollector() | 
| 810 : test_(new rtc::RefCountedObject<RTCStatsCollectorTestHelper>()), | 974 : test_(new rtc::RefCountedObject<RTCStatsCollectorTestHelper>()), | 
| 811 collector_(FakeRTCStatsCollector::Create( | 975 collector_(FakeRTCStatsCollector::Create( | 
| 812 &test_->pc(), 50 * rtc::kNumMicrosecsPerMillisec)) { | 976 &test_->pc(), 50 * rtc::kNumMicrosecsPerMillisec)) { | 
| 813 } | 977 } | 
| 814 | 978 | 
| 815 protected: | 979 protected: | 
| 816 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; | 980 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; | 
| 817 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 981 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 
| 818 }; | 982 }; | 
| 819 | 983 | 
| 820 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 984 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 
| 821 collector_->VerifyThreadUsageAndResultsMerging(); | 985 collector_->VerifyThreadUsageAndResultsMerging(); | 
| 822 } | 986 } | 
| 823 | 987 | 
| 824 } // namespace | 988 } // namespace | 
| 825 | 989 | 
| 826 } // namespace webrtc | 990 } // namespace webrtc | 
| OLD | NEW |